From: Ken Bloom Date: 2007-06-13T07:10:20+09:00 Subject: Re: using ` and the bash source command On Mon, 11 Jun 2007 12:56:19 +0900, Kevin Jackson wrote: > Hi, > >> If you were to run your Java program itself from ruby, I would think >> that you could set the JAVA_HOME environment variable directly with >> ENV[JAVA_HOME] = whatever you want, before executing Java as a >> child process of the Ruby program. > > I cannot run the Java code from the ruby program as I could be running > one of several apps. > > I actually got the behaviour I wanted by writing to .bashrc instead of > bash_profile, so now my workflow is: > - run jdk_switcher -> open terminal -> run cli java app instead of: > - vi .bashrc -> modify JAVA_HOME -> open new terminal -> run cli java > app. > > It's a hell of a lot quicker than manually editing each time and I'm > fairly happy with the results and there's no need for the source command > at all as the .bashrc is read every time I open a new terminal > > Anyway, thanks for the help/suggestions I don't particulary like that, (it seems too hackish) but that's just me. If there aren't too many different configuration options consider creating a shell function that does all of the reconfiguration itself[1], if there are too many options and this really demands a gui then have your gui write to a separate configuration file, create a shell function or alias that reloads that file (alias rejdk="source ~/.jdk_config_file") and run that manually in your shell each time you update the config file. --Ken [1] Option 1 would live in your .bashrc, and might look something like this: setjdk(){ case $1 in gcj) export JAVA_HOME=... ;; 1.6) export JAVA_HOME=... ;; 1.5) export JAVA_HOME=... ;; 1.4) export JAVA_HOME=... ;; kaffe) export JAVA_HOME=... ;; esac } -- Ken Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/