0

All I want to do is have my GUI .java program compile code that the user specifies.

Process p = Runtime.getRuntime().exec("javac theirJavaFileName.java");

Whenever I run this, I simply get:

java.io.IOException: Cannot run program "javac theirJavaFileName.java" CreateProcess error=2, The system cannot find the file specified

When I run my commands (which are a little more complex in my program), the code compiles fine through CMD. What could be the problem?

Thanks!

PS all variables are defined correctly: My code looks like this:

Process p = Runtime.getRuntime().exec("javac -classpath \"" + fileDestination + "\" \"" + file.getAbsolutePath() +"\"");

ToXSiK

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by mKorbel
0

Hmm... Do you really need double quotation when you run command line??? I never have it in my command line compilation.

//i.e.
>javac -classpath foo.jar MyClass.java
0

Hey! Thanks for responding. I have tried it all different ways, I do not know what the problem is :/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.