I have a java desktop application that contains the following code:
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
System.out.println("check1");
int intResult = compiler.run(System.in, System.out, foutErrorFile, strvalidatePath);
System.out.println("check2");
When I run the corresponding .jar file of this application by executing "java -jar name.jar", both check1 and check2 gets printed and app works fine. But when i try to run the jar by double clicking the .jar file, I found that ToolProvider.getSystemJavaCompiler() is returning null. "check2" does not get printed. I dont get proper result from compiler.run().
I did modify the registry entry "\HKEY_CLASSES_ROOT\jarfile\shell\open\command" from "C:\Program Files\Java\jre1.6.0\bin\javaw.exe" -jar "%1" %* to "C:\Program Files\Java\jre1.6.0\bin\java.exe" -jar "%1" %*. This way I'm able to see the console when the app is running.
So why is my program (which runs fine while run using java -jar command) malfunctioning when I run the .jar file by double-clicking?