i am writing a program which asks the user to select a a java file. I would then like to take this file and compile it
File theFile = chooser.getSelectedFile();
How would i compile this file from within my java program
I found this article. Take a look at it:
Running external commands in Java applications
The Java(TM) 2 Platform, Standard Edition team will be making a change that might impact you.
The change is that the class "sun.tools.javac.Main" (used for compiling java classes) will be removed in J2SE 1.4.
This is not a public API change. If you depend on this class you may be impacted.
If you have questions, please follow-up with your designated Licensee Engineer.
Java Partner Engineering
You could use the Compile Class of tools. But since neither of these is technically available for the public, and therefore not handled with that consideration in mind, you would be at some risk.