Thanks Alexey,

This works now. Actually I had to also specify the version of the source. When I only specify the -target this is what I get:
[EMAIL PROTECTED] bin]$ ~/jdk1.5.0_06/bin/javac -target 1.4 Test.java
javac: target release 1.4 conflicts with default source release 1.5

However, when i specify both -source and -target, it works fine.
[EMAIL PROTECTED] bin]$ ~/jdk1.5.0_06/bin/javac -target 1.4 -source 1.4 
Test.java
[EMAIL PROTECTED] bin]$ ./java Test
Hello World


Alexey Petrenko wrote:

-------Suns JDK --------------------------------
[EMAIL PROTECTED] bin]$ ~/jdk1.5.0_06/bin/javac -version
javac 1.5.0_06

[EMAIL PROTECTED] bin]$ ~/jdk1.5.0_06/bin/javac Test.java

[EMAIL PROTECTED] bin]$ ./java Test
Exception in thread "main" java.lang.UnsupportedClassVersionError:
(Test) bad major version at offset=6
It easy :)
You've compiled a class with 1.5 compiler and then run it on 1.4 VM.
You can fix this issue by two ways:
1. Complile the class with -target 1.4 javac option
(~/jdk1.5.0_06/bin/javac -target 1.4 Test.java) and run as ./java Test
2. Compile without target option as you did it before and run on 1.5
VM (~/jdk1.5.0_06/bin/java Test)

This should help.

--
Alexey A. Petrenko
Intel Middleware Products Division

--
Karan Singh

Reply via email to