brian_s
asked on
Runtime.exec from a servlet ?
can Runtime.exec be run from a servlet?
yes, I think so.
ASKER
it works fine when i do:
javac Example.java
java Example
however from a servlet it doesn't work
javac Example.java
java Example
however from a servlet it doesn't work
ASKER
if i cut and paste the command string from my java program and paste it into the dos prompt it works fine-
so something is going wrong from servlet to cmd line execution
please help
so something is going wrong from servlet to cmd line execution
please help
ASKER
if i cut and paste the command string from my java program and paste it into the dos prompt it works fine-
so something is going wrong from servlet to cmd line execution
please help
so something is going wrong from servlet to cmd line execution
please help
ASKER
if i cut and paste the command string from my java program and paste it into the dos prompt it works fine-
so something is going wrong from servlet to cmd line execution
please help
so something is going wrong from servlet to cmd line execution
please help
Running a command from the command line, is not the same as running it from exec.
The problems probably because of an environement difference.
Ensure you include the full pathname of the executable you are trying to run, and that you supply all the required environment variables.
Or run your command with the command shell.
The problems probably because of an environement difference.
Ensure you include the full pathname of the executable you are trying to run, and that you supply all the required environment variables.
Or run your command with the command shell.
ASKER
I have it running from the exec if I just invoke that class...
javac whatever.java
java whatever
and it'll work just fine
However, the same exec code through a servlet doesn't work. No errors are generated!?
I'm using Websphere v3.52 on NT
thanks
javac whatever.java
java whatever
and it'll work just fine
However, the same exec code through a servlet doesn't work. No errors are generated!?
I'm using Websphere v3.52 on NT
thanks
Again the servlet runs in a different environment than what your user login does.
What's the error your getting?
What's the error your getting?
ASKER
I'm not getting any errors, but the process's exitCode() is returning 1 if that helps.
Sorry it took so long for me to get back to this... I tried to get in but Experts was down-
If I watch the task manager on the NT box while I click on the link in my servlet, I first see a CMD.EXE start than a JAVA.EXE
so it seems as if they are both starting, just not properly finishing
any ideas
Sorry it took so long for me to get back to this... I tried to get in but Experts was down-
If I watch the task manager on the NT box while I click on the link in my servlet, I first see a CMD.EXE start than a JAVA.EXE
so it seems as if they are both starting, just not properly finishing
any ideas
ASKER
here is some of my code if it helps:
Runtime RunTime = Runtime.getRuntime();
Process process = null;
String dir = "c:\\websphere\\appserver\ \hosts\\de fault_host \\ias\\jav a_source\\ ",
swfName = dir + ProjectId,
template = dir + "one.swt",
myExe;
try{
myExe = "cmd /c c:\\jgenerator-1.3.0\\bin\ \jgenerate .cmd -param projectName " + "\"" + ProjectName + "\"" +
" -param sectionOne "+ "\"" + sectionOne + "\"" +
" -param sectionTwo "+ "\"" + sectionTwo + "\"" +
" -param sectionThree "+ "\"" + sectionThree + "\"" +
" -param sectionFour "+ "\"" + sectionFour + "\"" +
" -param sectionFive "+ "\"" + sectionFive + "\"" +
" -param sectionSix "+ "\"" + sectionSix + "\"" +
" -param paragraphOne "+ "\"" + paragraphOne + "\"" +
" -param paragraphTwo "+ "\"" + paragraphTwo + "\"" +
" -param paragraphThree "+ "\"" + paragraphThree + "\"" +
" -param paragraphFour "+ "\"" + paragraphFour + "\"" +
" -param paragraphFive "+ "\"" + paragraphFive + "\"" +
" -param paragraphSix "+ "\"" + paragraphSix + "\"" +
" -swf " + swfName + ".swf " + template;
System.err.println(myExe);
process = RunTime.exec(myExe);
System.err.println("got here also.... process = " + process);
try {
int rc = process.waitFor();
}
catch (InterruptedException ie) {
System.err.println(ie);
}
System.out.println("proces s returned " + process.exitValue());
process.destroy();
}
catch (IOException e){
System.err.println("_DbFla sh CreateSWF failed! IOException... stacktrace-->");
e.printStackTrace();
}
NO exceptions are thrown.....
Runtime RunTime = Runtime.getRuntime();
Process process = null;
String dir = "c:\\websphere\\appserver\
swfName = dir + ProjectId,
template = dir + "one.swt",
myExe;
try{
myExe = "cmd /c c:\\jgenerator-1.3.0\\bin\
" -param sectionOne "+ "\"" + sectionOne + "\"" +
" -param sectionTwo "+ "\"" + sectionTwo + "\"" +
" -param sectionThree "+ "\"" + sectionThree + "\"" +
" -param sectionFour "+ "\"" + sectionFour + "\"" +
" -param sectionFive "+ "\"" + sectionFive + "\"" +
" -param sectionSix "+ "\"" + sectionSix + "\"" +
" -param paragraphOne "+ "\"" + paragraphOne + "\"" +
" -param paragraphTwo "+ "\"" + paragraphTwo + "\"" +
" -param paragraphThree "+ "\"" + paragraphThree + "\"" +
" -param paragraphFour "+ "\"" + paragraphFour + "\"" +
" -param paragraphFive "+ "\"" + paragraphFive + "\"" +
" -param paragraphSix "+ "\"" + paragraphSix + "\"" +
" -swf " + swfName + ".swf " + template;
System.err.println(myExe);
process = RunTime.exec(myExe);
System.err.println("got here also.... process = " + process);
try {
int rc = process.waitFor();
}
catch (InterruptedException ie) {
System.err.println(ie);
}
System.out.println("proces
process.destroy();
}
catch (IOException e){
System.err.println("_DbFla
e.printStackTrace();
}
NO exceptions are thrown.....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hello objects.. just logged in to this site for the first time in a while
although i never figured this out (did it through a workaround)... you did help alot so here's the points
although i never figured this out (did it through a workaround)... you did help alot so here's the points
Thanks.