• Post Reply Bookmark Topic Watch Topic
  • New Topic

javax.tools.JavaCompiler compile java file  RSS feed

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I use the class javax.tools.JavaCompiler (jdk6) to compile a dynamic source file, but the source file depends on some jar file.how should i do it.

here is my code



here the code shows compile time errors for import files.


How to add jar files to compile my java file
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you had this jar file under classpath then you can do this way load the jars file.



It tested and working fine for me.
While considering its not a good idea to load all the jars instead of dependent and looking forward for the right technique.
 
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add tools.jar to your classpath. In Netbeans, this can be done by right-clicking on libraries ->Add Jar/Folder in your project column.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!