|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xml.utils.synthetic.JavaUtils
This class supports invoking Java compilation from within a Java program. Recent versions of the Java environment have provided such an API (in tools.jar). But that isn't available on all platforms, and a fallback to the command line may be needed (though this too may not always be available, eg. for security reasons).
There's an additional complication in some environments -- such as Microsoft's VJ++ -- where the classpath as seen in the System Properties may not be the one the user expects. The code here is parameterized to try to deal with that.
Field Summary | |
private static boolean |
cantLoadCompiler
|
private static boolean |
debug
|
Constructor Summary | |
JavaUtils()
|
Method Summary | |
static boolean |
JDKcompile(String fileName,
String classPath)
Try to compile a .java file on disk. |
static void |
setDebug(boolean newDebug)
Control whether compilation occurs with the -g option (debugging information included in generated classfile). |
(package private) static int |
waitHardFor(Process p)
Subroutine: Like p.waitFor, but discards the InterruptedException and goes right back into a wait. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static boolean cantLoadCompiler
private static boolean debug
Constructor Detail |
public JavaUtils()
Method Detail |
public static void setDebug(boolean newDebug)
TODO: Consider whether debug should be a parameter.
public static boolean JDKcompile(String fileName, String classPath)
NOTE: This must be _compiled_ with sun.java.tools.* (tools.jar) available. We could change that to use reflection instead, if we accept some overhead... minor compared to the cost of running the compiler!
This has complications on some platforms. For example, under Microsoft Visual Java ++ (at least, as installed on my test system), I found that I had to specify paths to both javac and xerces.jar rather than counting on the shell's path and classpath having been set to reach these. For that reason I've parameterized this method with a few system properties, so you can adapt it to your own system's needs without modifying the code:
static int waitHardFor(Process p)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |