问题
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.
Compile the Source code using Java-7.
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