Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compiling a file from the GUI

 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have to write a GUI which will get a java file, modify it, and execute it. I am ok with the modification part, but am stuck on how to compile it from the GUI and execute it. Any help is appreciated.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I will check it out.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is to include the tools.jar that comes with your JDK into your class path and the use the com.sun.tools.javac.Main class to compile the classes>:



With this snippet you will get the compilation errors printed in the system output, but you could use any other PrintWriter.
[ October 23, 2006: Message edited by: Edwin Dalorzo ]
 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried the options, but it seems to execute only if the java file compiled is in the same directory. however, the compiling works. What should I do if the file is in a different folder? let's say the folder is "c:\javacodes\filetesting". how do i execute a java file that is present in this directory?

Any help is appreciated.
 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i found out how to do that. Thanks for your help. However, now i am facig a new problem. the execution has to generate a text file. i am unable to find out where that file has been generated.

can somebody help me on this please?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic