David Gamey wrote:
> And is there an easy way to reference both?

Define "easy".  :)

I have to run tests using several versions of Java and
so took some time to set up some Z-shell functions to
make switching between them easier.  But this is on
Linux (and zsh, obviously) and I've never looked at
other environments.

I can switch between java versions with a single command.
For example, to use Sun's JDK 1.6, I type:

-> jset6

and then just run 'javac' and 'java' normally (including
from inside other scripts).

Here's the jset6 function:
-------------------------------------------
#(name) jset6           - set up for using Java 1.6
jset6() {
     if [ -z "${CLASSPATH_PREFIX}" ]; then
         setenv CLASSPATH_PREFIX "."
     fi
     if [ ! -z "${JAVA_HOME}" ]; then
         # Clear remnants of previous JAVA
         delenvp PATH ${JAVA_HOME}
         delenvp CLASSPATH ${CLASSPATH_PREFIX}
         delenvp CLASSPATH ${JAVA_HOME}
     fi
     setenv JAVA6 /opt/java6
     setenv JAVA_HOME=$JAVA6
     addenv CLASSPATH ${JAVA_HOME}/jre/lib/jrt.lib
     addenv CLASSPATH ${CLASSPATH_PREFIX}
     addenv PATH ${JAVA_HOME}/bin
     }
-------------------------------------------

setenv, delenvp, and addenv are the functions that do
the heavy listing (well, delenvp and addenv are, setenv
just wraps 'export' so the call aligns with the other two).

delenvp removes all 'path' entries containing the 2nd argument from the
value of the variable named in the first argument.  Here, "path entries"
are assumed to be colon separated.

addenv prepends the second argument as a path entry on the value of
of the variable named in the first argument, *provided* that entry
isn't already on the PATH somewhere.

I have similar functions jset4 and jset5.

Given the primitive functions, it would be easy to do something
similar to allow switching between Icon and Unicon.  (I use them
to switch among other tasks as well as switching versions of Java.)

If you're curious about the implementations of addenv and delenvp
I can pass those on, but they are pretty zsh-specific.  I have no
idea what it would take to do something similar with a different
shell [or under Windows].


-- 
Steve Wampler -- [email protected]
The gods that smiled on your birth are now laughing out loud.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to