Reputation: 625
I compile java file by Runtime.exec("javac MyFrog.java"); It says no errors, doesn't output anything, but doesn't create MyFrog.class file. if i write Runtime.exec("javac") it outputs to output some help text. So I understand that program is working, but don't create class file. Permissions are ok.
Upvotes: 0
Views: 1581
Reputation: 94635
You can use ProcessBuilder or Runtime.exec() method to create new process,
String []cmd={"javac","Foo.java"};
Process proc=Runtime.getRuntime().exec(cmd);
proc.waitFor();
Or use ProcessBuilder
ProcessBuilder pb = new ProcessBuilder("javac.exe","-verbose", "Foo.java");
pb.redirectErrorStream(true);
Process p = pb.start();
p.waitFor();
InputStream inp=p.getInputStream();
int no=inp.read();
while(no!=-1)
{
System.out.print((char)no);
no=inp.read();
}
Upvotes: 0
Reputation: 28752
javac -verbose
should give you lot more information, specifically the directory where the file is created. Since you are able to recognize output help text without any parameters, I assume you are capturing the process's stderr and assume you are doing the same for stdout as well (though javac does not seem to write anything to stdout).
Where are you checking for the existence of the .class file? It is created in the same directory as the .java file. If MyFrog.java has a package declaration it will not be created in the package sub-dir; for that you have to use -d
argument.
Upvotes: 2
Reputation: 12054
make sure that MyFrog.java
is present in working directory
Upvotes: 0