简体   繁体   中英

execute java button in a jar from command line

I have a jar that I want just to get the output from that program. When we execute the jar, that will open a window and there are three button in that window. I need to click the second button, and after we click that button, it will open a new window and I need click another button there that open an file dialog, we need to choose a file and then click open. That is the program will produce the output. But, I want it to execute it without open the program jar interface, just use commandline like

java -cp test.jar click_button1 click_button2(file.txt)

so the user don't need to see the interface, the program just running on the backside.

Please advise and help. thank you.

Your question is difficult to understand.

But if you are looking for a way to send commands to the commandline from Java, you can use Runtime in Java:

http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#getRuntime%28%29

Runtime cmd = Runtime.getRuntime();
cmd.exec("java -cp test.jar click_button1 click_button2(file.txt)");

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