Class JavaUtilities


  • public class JavaUtilities
    extends java.lang.Object
    Common 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.String JDK_PATH  
      static java.lang.String[] JRE_CLASS_PATH  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JavaUtilities()
      Avoid initialization of utility class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String determineJDKDir()
      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.String getCommandOutput​(java.lang.String command)
      Executes the given command inside the command line and returns the result of the command.
      static boolean isJava9()
      Returns whether we are running Java 9.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JDK_PATH

        public static final java.lang.String JDK_PATH
      • JRE_CLASS_PATH

        public static final java.lang.String[] JRE_CLASS_PATH
    • Constructor Detail

      • JavaUtilities

        private JavaUtilities()
        Avoid initialization of utility class.
    • 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:
        1. Find the JDK via the JAVA_HOME system variable
        2. 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
      • 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:
        true for Java 9, false else