Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting ksh enviroment variables from Java

 
Adam J Smith
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adam J Smith
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic