Re: java 1.5 on 1.4.2



On Fri, 2005-04-29 at 03:00 +0200, Gerbrand van Dieijen wrote:
> oracle schreef:
> > Just need to verify something.
> >
> > You can not use a java 1.5 war file on a machine with java 1.4.2 loaded
> > on it.
> >
>
> That depends, you can compile Java 1.5 source code to a 1.4 class file.
> Then it will run fine on a java 1.4.2 JVM, even with the use of
> generics, and other java 1.5 extensions.

Hmm, I'd like a copy of your JVM... You can specify to javac the Source
Code and Target JVM versions you require. Specifying a lower Target
requires also that you set a lower Source.

So you can compile, for example, for 1.4, using:

javac -source 1.4 -target 1.4 MyClass.java

However, if MyClass.java uses *any* JDK 1.5 specific features (Generics,
For-each loop, etc), you'll get:

MyClass.java:5: generics are not supported in -source 1.4
(try -source 1.5 to enable generics)
static Vector<MyClass> v = new Vector<MyClass>();
^
1 error

(as already mentioned, the -source argument is mandatory in this case,
although I'm not sure if it implies the target).

Ross
--
[Ross A. Bamford] [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@xxxxxxxxxxxxxxxxxx


.



Relevant Pages

  • Re: target release conflicts with default source release
    ... Thomas Hawtin wrote: ... on some older Mac's that don't have Java 5. ... error message "target release conflicts with default source release 1.5" ... Consider this source code. ...
    (comp.lang.java.help)
  • Re: Something has to be tested and maintained was Re: GoTo in Java
    ... I am on record as saying that maintenance of source code is self defeating. ... every module or program when new functionality is added. ... is that a brick is a brick; it has the attributes and behaviours of a brick. ... to translate it to Java, and get something not too bad. ...
    (comp.lang.cobol)
  • Re: GoTo in Java
    ... >> to translate it to Java, and get something not too bad. ... > your 'cleaned up' Java now works the same as the Fortran code. ... NOT maintain source code. ... Encapsulate functionality and reuse it. ...
    (comp.lang.cobol)
  • Something has to be tested and maintained was Re: GoTo in Java
    ... to translate it to Java, and get something not too bad. ... Source code translations have been tried for several decades and they ... Because of its COBOL and procedural programming roots, ... Encapsulate functionality and reuse it. ...
    (comp.lang.cobol)
  • Re: OT: The Geek defense
    ... even if you don't cover the cost of development hours. ... least in Java. ... It isn't about source code and call structures; ... functionality you require is and break it into small components that can be ...
    (comp.lang.cobol)