aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes compiling a file from the GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "compiling a file from the GUI" Watch "compiling a file from the GUI" New topic
Author

compiling a file from the GUI

Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
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.


cheers,<br />Anandh
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
Thanks. I will check it out.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
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

Joined: Dec 15, 2004
Posts: 61
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

Joined: Dec 15, 2004
Posts: 61
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compiling a file from the GUI