diff options
Diffstat (limited to 'src/java/com/e1/pdj/JavacCompiler.java')
-rw-r--r-- | src/java/com/e1/pdj/JavacCompiler.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/java/com/e1/pdj/JavacCompiler.java b/src/java/com/e1/pdj/JavacCompiler.java new file mode 100644 index 0000000..7f2debe --- /dev/null +++ b/src/java/com/e1/pdj/JavacCompiler.java @@ -0,0 +1,34 @@ +package com.e1.pdj; + +import com.cycling74.max.MaxSystem; +import java.io.File; + +class JavacCompiler extends GenericCompiler { + + public JavacCompiler() { + super("javac"); + } + + String javacPath() { + String fullPath = System.getProperty("pdj.JAVA_HOME"); + File test = new File(new File(fullPath, "bin"), "javac"); + if ( test.exists() ) { + return test.getAbsolutePath(); + } + MaxSystem.post("unable to find 'bin/javac' from the JAVA_HOME, using PATH"); + return "javac"; + } + + void compileClass() throws PDJClassLoaderException { + String args = javacPath() + " " + resolvJavaFile() + + " -classpath " + getConfigurationClassPath() + + " -sourcepath " + PDJClassLoader.fclasses.toString(); + + int rc = exec(args); + + if ( rc != 0 ) { + throw new PDJClassLoaderException("pdj: compiler returned: "+ rc + ",args: " +args); + } + MaxSystem.post("pdj: compile successful"); + } +} |