How to Run Jar on java 7 compiled in java 8 or higher version [duplicate]

泄露秘密 提交于 2019-12-20 02:08:30

问题


I have created a windows application using java 8 . But my client is using java 7 on his machine and not able to upgrade java on the machine.

So when i run jar on java7 compiled in java 8 it gives error so can i convert jar compatible to lower version java


回答1:


You can't change a compiled jar's Java version. You have 2 option in hand.

  1. Compile the Source code using Java-7.

  2. Compile source code using Java-8 but using the following command when target vm version is java-7.

javac "Your java classes" -source 1.8 -target 1.7



回答2:


Java 7 is forward compatible with Java 8. Java 8 can be compiled so that it runs on a Java 7 VM (with -source 7 -target 7), but you can’t use any of the newer APIs. Just Compile with JAVA 7 and you would be good to go just make sure you are not using new features of java 8 like lamda




回答3:


You can't. You need to compile with Java 7. You can run multiple Java version and choose which version should be used to compile: Multiple Java versions running concurrently under Windows



来源:https://stackoverflow.com/questions/55648231/how-to-run-jar-on-java-7-compiled-in-java-8-or-higher-version

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