oracle schreef:
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