Class JKCompileUtil

java.lang.Object
com.jk.core.java.JKCompileUtil

public class JKCompileUtil extends Object
This class provides methods to extract class and package information from source code, retrieve class path, determine package directory, and compile Java source code dynamically.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKCompileUtil

      public JKCompileUtil()
  • Method Details

    • compileJavaClass

      public static boolean compileJavaClass(String sourceCode)
      This method compiles Java source code dynamically and returns whether the compilation was successful.
      Parameters:
      sourceCode - Specifies the Java Source Code to be compiled.
      Returns:
      true, if the compilation was successful, false otherwise.
    • getPackageDir

      protected static String getPackageDir(String sourceCode)
      This method determines the directory path corresponding to the package structure of the source code.
      Parameters:
      sourceCode - Specifies the java source code.
      Returns:
      The directory path of the package structure, or null if no package is defined.
    • getClassName

      public static String getClassName(String sourceCode)
      This method extracts and returns the name of the class from the Java source code.
      Parameters:
      sourceCode - Specifies the java source code.
      Returns:
      the name of the class extracted from the source code.
    • getPackageName

      public static String getPackageName(String sourceCode)
      This method extracts and returns the package name from the Java source code.
      Parameters:
      sourceCode - Specifies the java source code.
      Returns:
      the package name extracted from the source code, or null if no package is defined.