问题
How can I set my java jar application to use jre 6 instead of jre 7? I'm doing this because there are some compatibility issue with the libraries I'm using if the application use jre 7.
Edit: The application will come with its own installers (using advanced installer) that have a jre6 installer. But I don't know how to trace the installation folder of the jre6. How can I trace it and make the jar file use the jre6?
回答1:
When running your application using java.exe, you could provide the absolute path to a Java 1.6 installation. Something like:
absolute_path_to_java6_dir/bin/java -jar yourRunnableJar.jar
or
absolute_path_to_java6_dir/bin/java -cp .;yourJar.jar;otherJarFiles className
回答2:
You can do this from Advanced Installer much simpler. You have two options:
Force the package to use the JRE 1.6 found on the machine by going to "Virtual Machine" tab from Java Products page and setting the minimum and maximum JRE versions to 1.6
Add as bundle in the project from the same page the JRE for version 1.6. This means that Advanced Installer will automatically import in your package the JRE resources required for your application, thus increases the package size, and will install them in the application's install folder. This JRE bundle will be used only by your application and removed along with it.
回答3:
You could check the running JVM version when starting your application.
System.getProperty("java.version");
This way you could provide a meaningful explanation to end-user.
来源:https://stackoverflow.com/questions/13047122/how-to-set-jar-application-to-use-java-6-instead-of-7