简体   繁体   中英

how to run jar files from command prompt

I have executable jar file and want to run from command line along with the environment variable path as a parameter. In eclipse the code is running well by setting up the path variable in eclipse configuration.Please help.The command that i am trying is given below

java -jar jar_name

java -jar jar_name.jar -DsystemVariableName=value

Access this value in the code as System.getProperty("systemVariableName");

Environment variable can be directly accessed in the code as System.getEnv("EnvVarName");

Refer : https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getenv()

您需要执行以下操作:

java -jar <jar-file-name>.jar

java -jar jarfile.jar is the shortest answer possible but note that there are multiple things that maybe need to be set for the jar to run correctly as you may need to specify the Main class or the classpath .

This Oracle tutorials will help.

Please see the below link. It has all the information you need http://www.wikihow.com/Run-a-.Jar-Java-File .

java -jar <jar.file> <parameter> 

您可以定义多个参数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM