JAVA Compilation : compile with new JVM version and run on older version -


here small explanation of problem.

i have application compiled java 1.5. application installed on 2000 pc (blockboxes) installed @ customer premisses. jar of application updated add new feature , fixes, technical reasons, not easy update java version, must keep using java 1.5 on existing machines.

few months ago, got request new requirement application. fulfil task have added usage of hazelcast in application.

my problem if following: - hazelacast jar file needs java 1.6 or above, must compile application 1.6 - new functionality using hazelcast activated on demand settings new parameter. means not used in 2000 installed blackboxes. - new blackboxes installed jave 1.6 or above able use hazealcast functionality.

my problem want have unique source code , unique version of application old blackboses using java 1.5 , new blackboxes using 1.6 or above.

in beginning, idea compile version 1.5 , make sure new functionality activated in blockboses using java 1.6 or above. option not working, because when compile 1.5, compiler complains hazelcast jar file needs 1.6 :(

the second option compile 1.6, cannot sure application still work on blackboxes using 1.5. :(

i'm know if here know how solve kind of problem?

just let me know if explanation not clear ;)

thanks in advance help.

you can compile code java 1.5 bytecode using jdk 1.6, take care of following:

  • -source=1.5 , -target=1.5 compiler options

  • bootclasspath should point rt.jar jre 1.5

see post more info: http://www.draconianoverlord.com/2014/04/01/jdk-compatibility.html

the post recommends building application older jdk if possible. need figure out different build process , exclude incompatible libraries classpath. if use maven, consider having 2 pom.xml files, optional parent file.


Comments