This is a question that sounds funny, but when you think about it, how does it work? I tried it in the example below:
package folder;
public class JavaCompiler {
public static void main(String[] args){
//I use the Path class and passes it as an argument.
Path path = Paths.get("folder\\File.java");
new JavaCompiler().start(path);
}
public void start(Path path){
//
Process compiler = Runtime.getRuntime().exec("javac " + path.toAbsolutePath().toString());
}
}
And here is the class that I am compiling, easy enough right?
package folder;
public class File {
public static void main(String[] args){
System.out.println("Hello Java Compiler!");
}
}
So how would I do it?