Home arrow static arrow Java Programming [Archive] - Environment of process created by Runtime.exec()
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Environment of process created by Runtime.exec()
This topic has 3 replies on 1 page.

Posts:8
Registered: 8/5/04
Environment of process created by Runtime.exec()  
Aug 5, 2004 10:03 AM



 
Can anyone describe the interactions of the process environment created by Runtime.exec()?

For example, if Runtime.exec() is used as follows:

Runtime.exec("cmd /K somebatfile");

Is the environment preserved throughout the execution of somebatfile?
Rather, if the classpath, working directory, etc. is changed within "somebatfile" are those changes still preserved by the cmd shell if it is executed this way from Runtime?
 

Posts:426
Registered: 11/1/00
Re: Environment of process created by Runtime.exec()  
Aug 5, 2004 11:55 AM (reply 1 of 3)



 
A little confused on your last statement. If the cmd process changes any OS environment variables including working directory, these are not propagated to the parent process (Java).
 

Posts:31,095
Registered: 4/30/99
Re: Environment of process created by Runtime.exec()  
Aug 5, 2004 12:09 PM (reply 2 of 3)



 
are those changes still preserved by the cmd shell if it is executed this way from Runtime?

Look at it this way: the command shell doesn't know how it was started. All it knows is that it is running now.
 

Posts:8
Registered: 8/5/04
Re: Environment of process created by Runtime.exec()  
Aug 5, 2004 12:55 PM (reply 3 of 3)



 
That is the way I thought things worked. Thanx.

However, when I start my command script inside of a shell (with "cmd /K") I get a "file not found" error. The command generating the error is a java call loading a executable jar which uses jni to open sockets and I have no Idea what else. (I know about the sockets because of the failed socket messages that are generated after the file not found error). The source code for the launched application is not available.

If you can provide some other insight I would appreciate it.
 
This topic has 3 replies on 1 page.