Class JavaUtilities
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.JavaUtilities
-
public class JavaUtilities extends java.lang.ObjectCommon utility functions for Java operations which may be used by several instantiators.- Author:
- Sascha El-Sharkawy
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringJDK_PATHstatic java.lang.String[]JRE_CLASS_PATH
-
Constructor Summary
Constructors Modifier Constructor Description privateJavaUtilities()Avoid initialization of utility class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringdetermineJDKDir()Determines the PATH (root folder) of the installed and most used JDK installation.private static java.lang.String[]determineJREClassPath()Determines the JRE class path.private static java.lang.StringgetCommandOutput(java.lang.String command)Executes the given command inside the command line and returns the result of the command.static booleanisJava9()Returns whether we are running Java 9.
-
-
-
Method Detail
-
determineJDKDir
private static java.lang.String determineJDKDir()
Determines the PATH (root folder) of the installed and most used JDK installation. This algorithm will try the following things to detect the JDK installation:- Find the JDK via the JAVA_HOME system variable
- Find the JDK via the command where/whereis javac
- Returns:
- The location of a JDK (top folder) or null if it could not be found.
- See Also:
- JAVA_HOME system variable, Source of the used algorithm
-
getCommandOutput
private static java.lang.String getCommandOutput(java.lang.String command)
Executes the given command inside the command line and returns the result of the command. Part of thedetermineJDKDir()method.- Parameters:
command- A windows or unix command to execute on the command line.- Returns:
- The result of the executed command.
- See Also:
- http://stackoverflow.com/questions/15725601/finding-jdk-path-and-storing-it-as-a-string-in-java
-
determineJREClassPath
private static java.lang.String[] determineJREClassPath()
Determines the JRE class path.- Returns:
- String array containing all libs
-
isJava9
public static boolean isJava9()
Returns whether we are running Java 9.- Returns:
truefor Java 9,falseelse
-
-