Wednesday, 13 June 2018

How to start a Java program (jar) from another Jar


We can start a jar inside another jar and get the result by below code.

Process proc = new ProcessBuilder("java", "-XMx8192M", "-jar", "test.jar").start();
int result = proc.waitFor();

You can get details of ProcessBuilder from below.

https://docs.oracle.com/javase/10/docs/api/java/lang/ProcessBuilder.html

No comments:

Post a Comment

Thank You for your valuable comment

Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...