简体   繁体   中英

Execute a JAR file with run time arguments

I have a JAR file created from Eclipse. Another developer wants to run the JAR with his given inputs. The process in the JAR file should keep running on the other machine and that developer should be able to provide the inputs at his will. Is this possible?

I have created the JAR file with taking inputs from the Command Line. But this won't serve my purpose.

Yes is possible. If you eg add class with main method, then you can add many arguments, and get it from main(String... args) args inputs.

JAVA Documentation says :

java [ options ] -jar file.jar [ argument ... ]

and

... Non-option arguments after the class name or JAR file name are passed to the main function...

Try the following while executing:

java -jar <jarName> <ARGUMENT1> <ARGUMENT2> 

where jarName is the jar file, followed by the arguments you want to provide.

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