• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Unix env variables not available to Java Process

 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys : I'm launching a java process which launches a unix program.

Unfortunately, all the variables in my shell (that I would see if I type "env" for example) are not available to the process, even though some of the basic path names are.

How can I ensure that my java spawned process object has access to the same env and $PATH information that my terminal (which i typically just launch from a desktop in mac os x) does ?

Thanks....

ps here is the path information that is available if i run env from inside of java

SHELL=/bin/bash,TMPDIR=/var/folders/Yw/YwCN+82sEsen96EUXzUFRU++-1A/-Tmp-/,Apple_PubSub_Socket_Render=/tmp/launch-x4VpMS/Render,USER=mattf,COMMAND_MODE=unix2003,SSH_AUTH_SOCK=/tmp/launch-1mnYOH/Listeners,__CF_USER_TEXT_ENCODING=0x433:0:0,APP_ICON_49848=../Resources/Eclipse.icns,PATH=/usr/bin:/bin:/usr/sbin:/sbin,PWD=/Network/Servers/macsent.cluster.uchc.edu/Volumes/raid/Users/mattf/Documents/workspace/ConnjurUtilities,JAVA_MAIN_CLASS_58129=connjur.utils.wrappers.process.processutils.vyas.unix.CommandExecutorUNIX,SHLVL=1,HOME=/Network/Servers/macsent.cluster.uchc.edu/Volumes/raid/Users/mattf,JAVA_STARTED_ON_FIRST_THREAD_49848=1,LOGNAME=mattf,DISPLAY=/tmp/launch-0s4NsP/:0,SECURITYSESSIONID=61230e0,_=/usr/bin/env


 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not use java.lang.ProcessBuilder?

It lets you define environment variables very conveniently.

Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic