Runtime.exec gives problem in unix environment

P

Priyanka AGARWAL

Hi,
I have a problem with Runtime.exec() call.

I have used the following code:
String[] env = null;
Process wait = Runtime.getRuntime.exec(exeCmd , env ,workingDir);
.................
.................
My exe command uses some external application which has environment
settings.
If I give the env as null it takes the default environment settings
in windows and works fine in windows .But it doesnt work in UNIX,
it doesnt take the default environment settings in unix.
I have tried using String[] env = {""} , still it doesnt work in unix.

I want my code to work both on windows and unix.

Is there a solution???
Priyanka
 
G

Guest

Priyanka said:
Hi,
I have a problem with Runtime.exec() call.

I have used the following code:
String[] env = null;
Process wait = Runtime.getRuntime.exec(exeCmd , env ,workingDir);
.................
.................
My exe command uses some external application which has environment
settings.
If I give the env as null it takes the default environment settings
in windows and works fine in windows .But it doesnt work in UNIX,
it doesnt take the default environment settings in unix.

Specification said:

The environment variable settings are specified by envp.
If envp is null, the subprocess inherits the environment
settings of the current process.

So when your env is null the subprocess does NOT take
a default environment settings, BUT it inherits the environment
settings of the current Java process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top