"javac -source 10 -target 10" - Lower Java Version
How to lower the Java version in the bytecode? I want to generate class files for an older Java environment.
If you want generate class files for an older Java environment, you need to use "-source x" and "-target x" options in the "javac" command to compile the Java source code.
1. Check the default version of Java compiler:
> javac -version javac 15
2. Compile HelloWorldFrame.java used in the last tutorial into a bytecode file with the default version:
> javac HelloWorldFrame.java
3. Check the version of the bytecode. Bytecode major version 59 maps to Java 15.
> javap -v HelloWorldFrame.class | grep "major version" major version: 59
4. Compile HelloWorldFrame.java again for Java 10:
> javac -source 10 -target 10 HelloWorldFrame.java warning: [options] system modules path not set in conjunction with -source 10 1 warning
5. Check the version of the bytecode again. Bytecode major version 54 maps to Java 10.
> javap -v HelloWorldFrame.class | grep major major version: 54
This bytecode can be executed in Java 10 environment.
â‡‘â‡‘ Java Bytecode Tools
2021-09-09, 402👍, 0💬
What Is poi-contrib-3.5.jar? poi-contrib-3.5.jar is one of the JAR files for Apache POI 3.5, which p...
JRE 8 plugin.jar is the JAR file for JRE 8 Java Control Panel Plugin interface and tools. JRE (Java ...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
How to download and install ojdbc11.jar for Oracle 21c? ojdbc11.jar for Oracle 21c is a Java JDBC Dr...