Hi,
Instead from command prompt, I am trying to execute java commands like 'javac', 'java' using java program. I have tried Runtime.getRuntime().exec() but it only executes the DOS commands like 'del'. samples those i tried are:
with taking commands as String[],
1.
commands[0] = "cmd";
commands[1] = "javac C:\\test.java";
2.
commands[0] = "cmd";
commands[1] = "javac";
commands[2] = "C:\\test.java";
3.
commands[0] = "cmd";
commands[1] = "set";
commands[2] = "path=C:\\Program Files\\IBM\\WebSphere Studio\\Application Developer IE\\v5.1\\runtimes\\base_v5\\java\\bin";
commands[3] = "javac C:\\test.java";
But none of above is working...no error/exception occurs but nothing happen. Just command prompt comes and disappears but no other action is happening....only DOS command such as following 'del' is working:
commands[0] = "cmd";
commands[1] = "del";
commands[2] = "C:\\test.java";
The lines used to execute are:
Runtime r= Runtime.getRuntime();
Process p=null;
try
{
p=r.exec(commands);
}catch(Exception e)
{
System.out.println("Exception is:- "+e.getMessage());
}
Could you please tell me what is the way to execute java commands using java programming language?
My ultimate intention is to execute java commands (jar - xvf and other commands) to jar and unjar the files using java program instead command prompt.