2

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.

Joseph
  • 335
  • 1
  • 3
  • 13
  • 1
    There is no guaranteed way to do it. Especially on Linux. But see this question for some possible tricks: https://stackoverflow.com/q/6493856/3920048 – Misha Jul 05 '18 at 19:21

0 Answers0