aspose file tools*
The moose likes Java in General and the fly likes Java code to compile and run another java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java code to compile and run another java program" Watch "Java code to compile and run another java program" New topic
Author

Java code to compile and run another java program

Haritha Gorijavolu
Greenhorn

Joined: Feb 18, 2011
Posts: 21

I asked the above question out of curiosity. For example, there is a xxx.java file in some location with it's own main method. What my code is required to do is compile and run xxx.java, given the location of the file. It is possible to do this in java?
Nico Van Brandt
Ranch Hand

Joined: Mar 31, 2011
Posts: 66

It is possible to run dos commands from a java program.

So I assume it's also possible to execute a javac


Oracle Java SE6 Certified Programmer
Oracle Java EE5 Certified Web Component Developer
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

If you use the java.exe that belongs to the JDK you can also use javax.tools.JavaCompiler.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Haritha Gorijavolu
Greenhorn

Joined: Feb 18, 2011
Posts: 21

Thank you all for answering.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java code to compile and run another java program