If you are distributing JRE with your application and you happen to also distribute
tools.jar as well. The you have probably copied
tools.jar to the jre/lib/ext folder.
This is viable option and have worked for me in the past (i.e. with Java 5 and Java 6). However this does not work in Java 7. If you do this in Java 7 you won’t get system compiler instance for example (i.e. executing code
javax.tools.ToolProvider.getSystemJavaCompiler() will return
What I found out (painfully) that in Java 7 you have to put
tools.jar directly to the jre/lib folder!!!
When you do this you can execute
javax.tools.ToolProvider.getSystemJavaCompiler() and get a compiler instance as expected.
Oracle has accepted bug report for this problem. You can see it in Oracle’s bug database as 7181951.
Oracle has closed the bug with the following evaluation:
Closing as not a bug. That behavior was neither specified nor intended.
Posted Date : 2012-07-13 15:57:50.0
So I guess it means that the only true place for
tools.jar is the jre/lib folder!
Leave a Reply