Package com.jk.core.java
Class JKCompileUtil
java.lang.Object
com.jk.core.java.JKCompileUtil
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compileJavaClass
(String sourceCode) This method compiles Java source code dynamically and returns whether the compilation was successful.static String
getClassName
(String sourceCode) This method extracts and returns the name of the class from the Java source code.protected static String
getPackageDir
(String sourceCode) This method determines the directory path corresponding to the package structure of the source code.static String
getPackageName
(String sourceCode) This method extracts and returns the package name from the Java source code.
-
Constructor Details
-
JKCompileUtil
public JKCompileUtil()
-
-
Method Details
-
compileJavaClass
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
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
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
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.
-