You may try a combination of two open source libraries: [jaxec](https://github.com/yegor256/jaxec) and [jhome](https://github.com/yegor256/jhome) (I'm an author of them). This is how you call a Java program from your Java program:
```
import com.yegor256.Jaxec;
import com.yegor256.Jhome;
// compile it first:
new Jaxec()
.with(new Jhome().path("bin/javac").toString())
.with("Hello.java") // the file name
.exec();
// next, execute it:
new Jaxec()
.with(new Jhome().path("bin/java").toString())
.with("Hello") // the name of the class
.exec();
```
Behind the scene, it will find the location of `JAVA_HOME` and call `ProcessBuilder` to run two new processes.
You may try a combination of two open source libraries: [jaxec](https://github.com/yegor256/jaxec) and [jhome](https://github.com/yegor256/jhome) (I'm an author of them). This is how you call a Java program from your Java program:
```
import com.yegor256.Jaxec;
import com.yegor256.Jhome;
new Jaxec()
.with(new Jhome().path("bin/javac").toString())
.with("Hello.java")
.exec();
new Jaxec()
.with(new Jhome().path("bin/java").toString())
.with("Hello") // class name
.exec();
```
The absolute path of `bin/java` and `bin/javac` is calculated by `Jhome`.