I need to run a Java application from my application (Java too), but I need to be able to evaluate the Java version to use. The application I need to run requires Java 1.7+ but not all are fully compatible so I would like to be able to use the most appropriate Java version that is installed in this order:
String preferredJavaPath;
if (Java 1.8 is installed) {
preferredJavaPath = Java 1.8 Path
} else if (Java 1.7 is installed) {
preferredJavaPath = Java 1.7 Path
} else {
preferredJavaPath = current version running.
}
if (preferredJavaPath < 1.7) {
Show warning message.
}
Run APP2 using "preferredJavaPath"
I am currently using System.getProperty("java.home")
to get the location of the Java version by default (current version).
I need it to work on both Windows and Linux and MacOS.
I have been researching on the internet but the majority refers only to Windows and with not very good results.