How to set jar application to use Java 6 instead of 7

三世轮回 提交于 2019-12-08 01:59:33

问题


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:

  1. 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

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!