0
Issues while using Runtime exec()
Hey everyone! I've just learned to use the Runtime.getRuntime().exec() command, and it executed aĺl the files and cmd commands i've tested. But when i tryed to execute a prompt command to execute a java class, it didn't do anything. I used the following line of code: //After compiling the java code try { Runtime.getRuntime().exec("cmd /c java " + className); } catch(Exception e) {} If you see an error, i'll be thankful if you tell me.
4 Antworten
+ 1
wow Sorry i cant help you,what i did in the cmd was simple
+ 1
No problem. God bless you
0
Tell me ALL that you've did in the cmd
0
First i wrote a java file using Scanner. Then i used the following command in order to compile the file:
Runtime.getRuntime().exec("cmd /c javac " + dir + fileName + ".java");
After compiling, i should execute the generated class. Here's the commands:
Runtime.getRuntime().exec ("cmd /c java " + dir + className);
And that's the part when the command seems to fail, and nothing happens, not even an error message.
The same problem happens when i try to execute or create a .jar file:
Executing:
Runtime.getRuntime().exec("cmd /c java -jar " + fileName + ".jar");
Creating:
Runtime.getRuntime().exec("cmd /c jar cvfm " + fileName + ".jar" + manifest + " " + className + ".class");