I have a java application that at runtime shall spawn another JVM. Yet I want to package my application using jpackage, which works quite well. But at runtime, when my application tries to invoke the next JVM using
File javaHome = new File(System.getProperty("java.home"));
File java = new File(javaHome, "bin/java"); // may need a tweak on Windows
new ProcessBuilder().start(java.getAbsolutePath(), "-jar", ...);
I have to learn that the application was launched using a custom built JVM, and there just is no command such as 'java'. So the error I am getting is that this java.getAbsolutePath() cannot be executed.
Without the java executable, how can my application run another jar in a separate process? Can I reuse the JVM bundled with my application, or do I still have to provide another one?