Im having a compatible issue, my project is develop in JDK 1.6, but when i need to post it to a host domain, there is a issue where the host domain used JDK 1.5, how do i make my project compatible with JDK 1.5? thanks in advance
+7
A:
You basically need to set the -target
attribute. Also see javac /?
.
javac -target 1.5 [...]
Also see this example in javac's documentation.
Update: as per the comments you're using Eclipse, you can just change the compiler compliance level on a per-project basis. Rightclick project > Properties > Java Compiler > Compiler compliance level > 1.5. See screenshot.
You can download JDK 1.5 from the Sun Archive.
BalusC
2010-06-16 01:53:21
can i convert it straight a way in WAR file??
kojh
2010-06-16 02:07:49
No, the code must be compiled with 1.5 as the output language. The class file format has been changed in JDK6.
Yann Ramin
2010-06-16 02:10:26
Need `-source 1.5` as well, and putting the 1.5 `rt.jar` file in `-bootclasspath` is also very useful.
Tom Hawtin - tackline
2010-06-16 02:14:24
@kojh: if you're using an IDE (you should have make that more clear in your question), you need to set the project's compiler compliance level to 1.5 as answered by @mikera and then just rebuild the project.
BalusC
2010-06-16 02:15:49
thanks BalusC, im actually developing the my project using eclipse bundle with glassfish. Sorry for that :)
kojh
2010-06-16 02:20:34
BalusC does ur first suggestion still can be used to compile my projects even if i have eclipse ??
kojh
2010-06-16 02:39:10
Certainly. It's all up to you how you'd like to compile your code. Both can be used independently.
BalusC
2010-06-16 02:51:03
+3
A:
You should be able to set the compliance level on your compiler / IDE to 1.5 so that any incompatibilities are flagged (via compiler warnings). You can then fix whatever needs to be done to make your code 1.5 compatible.
In Eclipse for example, you go to Preferences / Java / Compiler and set the compliance level to 1.5. It's probably something similar in other IDEs.
mikera
2010-06-16 01:53:31