This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Runtime.exe()  is not working from a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Runtime.exe()  is not working from a jar file" Watch "Runtime.exe()  is not working from a jar file" New topic
Author

Runtime.exe() is not working from a jar file

Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi All,

I have a jar file which have classes and a package in it.
One of these classes is calling another class which is present in the package.
The code i am using it is as follows:
Runtime r=Runtime.getRuntime();


It is working fine when i am executing it without making jar file.
But when i make a jar file of all these things , this exec() is not working.
I have tried a lot.
If any body has any idea suggest me.
Thanks


Khushwinder
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
While you don't say what "not working" means, I think it may be a classpath issue. Make sure the subprocess knows where to find all required classes.

By the way, are you properly handling input/output/error streams for the subprocess?


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37939
    
  22
Originally posted by Ulf Dittmer:
. . . By the way, are you properly handling input/output/error streams for the subprocess?
If you search through the Ranch you find old threads like this one with links to Daconta's article, and also look at the ProcessBuilder class which makes it a bit easier by merging the output and error streams.
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
thanks for your valuable suggestions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Runtime.exe() is not working from a jar file
 
Similar Threads
build.xml: jar tag
Getting problem in jws
database file name
Running a RMI Application
How to run jar file?