Package com.install4j.api
Class JVMSelector
- java.lang.Object
-
- com.install4j.api.JVMSelector
-
public class JVMSelector extends java.lang.ObjectWith this class, you can retrieve the installed JVMs on Windows, Linux and Unix systems. Additionally, you can set the preferred VM for your application.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJVMSelector.JVMLocationThe interface providing information about a JVM.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JVMSelector.JVMLocationgetJVMLocation(java.io.File javaHome, java.lang.String minVersion, java.lang.String maxVersion, boolean jdkOnly)Checks if this directory contains a JVM with the specified parameters and returns the location object.static JVMSelector.JVMLocation[]getJVMLocations()Returns JVMs found in standard locations.static JVMSelector.JVMLocation[]getJVMLocations(java.lang.String minVersion, java.lang.String maxVersion, boolean jdkOnly, java.io.File[] additionalLocations)Returns JVMs found in standard locations with the given version requirements.static voidsetPreferredJVM(java.lang.String javaHome)Set the preferred JRE/JDK for your application.
-
-
-
Method Detail
-
getJVMLocations
public static JVMSelector.JVMLocation[] getJVMLocations()
Returns JVMs found in standard locations. On Windows the registry is used to get the JVMs. On Linux/Unix and macOS this method searches the usual locations for JVMs. Please be aware that this method can take some time on Linux/Unix as it executes java to gather version information.- Returns:
- an array of JVMLocation objects. See this class for more detail.
-
getJVMLocations
public static JVMSelector.JVMLocation[] getJVMLocations(java.lang.String minVersion, java.lang.String maxVersion, boolean jdkOnly, java.io.File[] additionalLocations)
Returns JVMs found in standard locations with the given version requirements. On Windows the registry is used to get the JVMs. On Linux/Unix and macOS this methods searches the usual locations for JVMs. Please be aware that this method can take some time on Linux/Unix as it executes java to gather version information.- Parameters:
minVersion- the minimum java versionmaxVersion- the maximum java versionjdkOnly- only JDKsadditionalLocations- additional locations that should be tested for JVMs- Returns:
- an array of JVMLocation objects. See this class for more detail.
-
getJVMLocation
public static JVMSelector.JVMLocation getJVMLocation(java.io.File javaHome, java.lang.String minVersion, java.lang.String maxVersion, boolean jdkOnly)
Checks if this directory contains a JVM with the specified parameters and returns the location object. The versions can be empty Strings if there should be no restriction.- Parameters:
javaHome- the directory to checkminVersion- the minimum java versionmaxVersion- the maximum java versionjdkOnly- only JDKs- Returns:
- a JVMLocation objects or null. See this class for more detail.
-
setPreferredJVM
public static void setPreferredJVM(java.lang.String javaHome)
Set the preferred JRE/JDK for your application. As long as this JRE/JDK exists and fulfills the version requirement of your application it will be used. This method has no effect on macOS.- Parameters:
javaHome- the base directory of the JDK/JRE.
-
-