Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24647

correctly setting system environment variables before calling Process.exec

Newsgroups comp.lang.java.programmer
Date 2013-07-05 04:13 -0700
Message-ID <b499dc2e-1935-4aeb-8885-1ff1091af027@googlegroups.com> (permalink)
Subject correctly setting system environment variables before calling Process.exec
From "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com>

Show all headers | View raw


I have a program that needs to set the DISPLAY environment variable before calling an external program so it will display correctly on remote X-Windows machines.   Note I *DO NOT* want it to be headerless i.e. I specifically can not and should not do java -Djava.awt.headless=true.   The reason is the program *MUST* run in a interactive xterm on the remote machine.  Here is something I tried with a no go:

import java.util.*;

public class Foo
{
        public static void main(String[] args)
                throws Throwable
        {
                Set<Map.Entry<String,String>> env=System.getenv().entrySet();
                String[] envOut=new String[env.size()+1];

                int i=0;
                for(Map.Entry<String,String> e:env)
                        envOut[i++]=e.toString();

                envOut[i]="DISPLAY=192.168.0.2:0.0";

                Runtime.getRuntime().exec("xterm",envOut);
        }
}

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

correctly setting system environment variables before calling Process.exec "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-07-05 04:13 -0700
  Re: correctly setting system environment variables before calling Process.exec "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-07-05 04:17 -0700

csiph-web