aspose file tools*
The moose likes Java in General and the fly likes Setting ksh enviroment variables from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Setting ksh enviroment variables from Java" Watch "Setting ksh enviroment variables from Java" New topic
Author

Setting ksh enviroment variables from Java

Adam J Smith
Greenhorn

Joined: Apr 23, 2008
Posts: 20
I have an application that will run in ksh that needs to set environment variables for another process to run.

I have tried


I also tried to create a shell script that takes two args and sets them to environment. When I run

I get


When I run

nothing happens.

I know another possibility is to use ProcessBuilder but I can find an example.
[ December 19, 2008: Message edited by: Adam J Smith ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Each time you call exec(), you're starting a new process; any changes made to the environment variables in a process will affect only that one process and its own children, not any other process you start with exec().

There are several Runtime.exec() methods; several of them take a String[] argument called "envp", which lets you pass environment variables to the process you're launching.


[Jess in Action][AskingGoodQuestions]
Adam J Smith
Greenhorn

Joined: Apr 23, 2008
Posts: 20
I was hoping I wouldn't have to do something like that. I am doing some maintenance on an old, and very poorly designed swing gui. The easiest solution seemed to be to set environment variables for the parent. I guess that may not be possible. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting ksh enviroment variables from Java