Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

notepad.exe process exist but it doesn't appear from a call Runtime.exec()

843798Sep 5 2006 — edited Sep 7 2006
Hi everybody. I have a problem with runtime.exec(cmd). I make the call from a jsp
wanting to launch a pdf or txt file to show it to user but it doesn't appear. I have realized that the process exist (notepad.exe or AcroRd32.exe i have hardcoded the exe's, before i was using explore.exe). It launchs the process but i don't know what happen because it doesn't appear on the screen. I have done a test with the same code in a main class and it works!. Im using WinXP and Tomcat 5.5. I checked logs and no errors are there.

This is the jsp code:

String cmd ="notepad.exe c:\\direccion.txt";
Runtime rt = Runtime.getRuntime();
//out.println(namePdf);
try {
Process proc = rt.exec(cmd);
System.out.println("Programa ejecutado!!!");
}catch(Exception e) {
out.println(e.getMessage());
e.printStackTrace();

and this is my main (isolated) class that works:

public class ClasePrueba {


public static void main(String[] args) {

String cmd ="explorer.exe c:\\direccion.txt";
Runtime rt = Runtime.getRuntime();
try {
Process proc = rt.exec(cmd);
}catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}

}

}


Please help me i have gone through this at least 15 days.

Message was edited by:
otherc

Message was edited by:
otherc

Message was edited by:
otherc

Message was edited by:
otherc

null
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2006
Added on Sep 5 2006
1 comment
162 views