File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Puneet Nayyar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Puneet Nayyar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're in a recent enough JDK, see ProcessBuilder, too. It's a friendlier way to build and run an exec() call.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic