I'm building a swing application which will be distributed using java webstart. It is kind of java editor where my app's users will be able to compile java source code.
The issue is -
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
It works fine in the dev env. But when I'm deploying my app using webstart, then in the client side, it returns null.It is because of the fact that my app is running on JRE instead of JDK. [System.getProperty("java.home") points to JRE]
To overcome this issue, I had followed the suggestion mentioned in the following SO thread.
I'm pointing java.home property to JDK's installation directory.
System.setProperty("java.home","C:\\DevEnv\\java");
Now ToolProvider.getSystemJavaCompiler();
returns valid compiler object, but I'm getting the following exception while compiling the java code with it. It is actually while calling the getStandardFileManager method of the compiler object.
Code
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
System.out.println("Compiler - " + compiler);
if(compiler!=null){
MyDiagnosticListener c = new MyDiagnosticListener(logWindow);
StandardJavaFileManager fileManager = compiler.getStandardFileManager(c, Locale.ENGLISH, null);
Iterable<String> options = Arrays.asList("-d", CLASS_OUTPUT_DIR);
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager,
c, options, null, files);
Boolean result = task.call();
}
Exception -
Please help me to resolve this issue.
ADD JNLP
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://<dynamic-ip>:8080/" href="ProjT.jnlp">
<information>
<title>Tectra</title>
<vendor>Manas Kumar Mukherjee</vendor>
<homepage href="http://<dynamic-ip>:8080/" />
<description>Testing Testing</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="Tools.jar" />
...
<jar href="log4j-1.2.16.jar" />
</resources>
<application-desc main-class="com.ui.DevMain" />
</jnlp>
Thanks