Java startup program, startup parameter explanation --add-exports

Java startup program, startup parameter explanation --add-exports

The full command looks like this:

java -Dlog4j.debug 
-Dlog4j.configuration=file:/data/src/Cassandra/log4j.properties 
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED 
--add-exports java.base/jdk.internal.ref=ALL-UNNAMED 
--add-exports java.base/sun.nio.ch=ALL-UNNAMED 
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED 
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED 
--add-exports java.sql/java.sql=ALL-UNNAMED 
--add-opens java.base/java.lang.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED 
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED 
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED 
--add-opens java.base/jdk.internal.math=ALL-UNNAMED 
--add-opens java.base/jdk.internal.module=ALL-UNNAMED 
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED 
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED 
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED 
--add-opens=java.base/java.io=ALL-UNNAMED 
-jar /data/src/cassandra-jar-with-dependencies.jar 
/data/src/Cassandra/config.properties

Parameter explanation:

  • --add-exports java.base/jdk.internal.misc=ALL-UNNAMEDis an option for the Java virtual machine startup parameters. It is used to specify that java.base/jdk.internal.miscall non-public APIs in a module are exported to all unnamed modules. This option is typically used to resolve compiler or runtime errors that occur when using a particular Java library or framework.

To use --add-exportsoptions, you need to include them in the startup command when executing your Java program. For example:

java 
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED 
YourProgram

Among them, YourProgramis the class name of the Java program to be executed.

Note that --add-exportsoptions are only available in Java 9 and later. In earlier versions of Java, you could try using --add-opensoptions to allow reflective access to non-public APIs. Make sure you understand the purpose and potential impact of these options when using them.

Guess you like

Origin blog.csdn.net/zhengzaifeidelushang/article/details/131685666