Runtime.exec gives problem in unix environment

Discussion in 'Java' started by Priyanka AGARWAL, Jun 28, 2004.

  1. 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
     
    Priyanka AGARWAL, Jun 28, 2004
    #1
    1. Advertising

  2. Priyanka AGARWAL wrote:

    > 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.
     
    =?UTF-8?B?IkRhcmlvIChkcmlua2luZyBjb++sgGVlIGluIHRo, Jun 28, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MARTIN Herve \(EXT\)
    Replies:
    1
    Views:
    1,462
    Anthony Borla
    Nov 27, 2003
  2. Priyanka AGARWAL
    Replies:
    4
    Views:
    5,251
    Priyanka AGARWAL
    Jul 23, 2004
  3. Jakir
    Replies:
    4
    Views:
    3,223
    Jakir
    Sep 1, 2004
  4. shallowpool
    Replies:
    2
    Views:
    7,329
    Gordon Beaton
    Apr 6, 2006
  5. Hal Vaughan
    Replies:
    11
    Views:
    1,119
    Gordon Beaton
    May 22, 2006
Loading...

Share This Page