Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch External Jar through Java Application

Tags:

java

Currently, I have an Java Standalone Swing Application.

Now, when user clicks on the button in the Swing Application, I would like to launch another Java Application (Say : calculator.jar)

May I know what is the portable way to do so? So that it will work in multiple OS?

like image 976
Cheok Yan Cheng Avatar asked Oct 14 '22 06:10

Cheok Yan Cheng


2 Answers

Either use Desktop#open() or just put it in classpath and invoke its main().

like image 53
BalusC Avatar answered Oct 19 '22 23:10

BalusC


You should be able to just use java to run the jar.

Runtime.getRuntime().exec("java -jar calc.jar");
like image 44
Milhous Avatar answered Oct 19 '22 22:10

Milhous