File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Passing runtime environment to child process on Solaris and citrix  from java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing runtime environment to child process on Solaris and citrix  from java program" Watch "Passing runtime environment to child process on Solaris and citrix  from java program" New topic
Author

Passing runtime environment to child process on Solaris and citrix from java program

Puneet Nayyar
Greenhorn

Joined: May 10, 2006
Posts: 4
I have an application that is supposed to launch an html page in netscape browser by executing a shell script.

So in my main code i am writing this:

String command = "start http:\\index.html"; //"start" is the shell script
Runtime.getRuntime().exec(command);

This code is working fine when i running it on Solaris but, the process doesn't launch through Citrix metaframe. It's searching for the user home in this case.

I suppose when a parent process launches a child process then the run time environment variables are also passed to the child. But in my case i am not getting the user home 'HOME' variable.

Is there any way by which i can pass the system environment variables manually to the child process in my java code?


Thanks
Puneet
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3168
    
  10
Have a look at the

version of exec. If you specify null for the envp and dir parameters it uses the calling processes environment and working directory.
[ June 08, 2006: Message edited by: Joanne Neal ]

Joanne
Puneet Nayyar
Greenhorn

Joined: May 10, 2006
Posts: 4
Thanks Joanne!!!
A small doubt i have here. If in envp array I specify some variables that are application specific and not system variables i.e. envp is not null. In this case calling processes environment is not getting passed to called process implicitly. But if I pass the environment variables in envp then the child process is getting all the required environment variables.

Does this means that if envp contains some variables then the System environment is not passed implicitly?

Regards,
Puneet
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3168
    
  10
I've never used the method myself but that's what I would expect to happen having read the Javadoc.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
If you're in a recent enough JDK, see ProcessBuilder, too. It's a friendlier way to build and run an exec() call.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing runtime environment to child process on Solaris and citrix from java program
 
Similar Threads
How to stop the server gracefully?
Setting environment variable in Ubuntu 10.4
Current directory not in path when logging via ssh
Update Java 1.4.1 to 1.4.2 in UNIX
Shell program locking up CD Drive