[CentOS] environment-modules

Thu Dec 24 20:51:54 UTC 2009
John R Pierce <pierce at hogranch.com>

m.roth at 5-cent.us wrote:
>> if you put /usr/java/jdk-whatever/bin first in the path, you'll be using
>> the Sun java.  if you take it out of the path, you will be using the
>> default distribution openjdk.
>>     
>
> I'm trying to provide a simple method for switching between the two, and I
> don't have any guarantee that someone *other* than this developer, who
> seems knowledgeable, will have to do the same thing.
>
> I reiterate: does anyone have any examples for a modulefile for java?
>   

lets assume that at profile time, the sun java is -not- in the path, and 
the usual /usr/bni stuff is.
in pseudocode as I'm a little too fried/tired to work out the real code 
and I haven't been coding sh/bash scripts in a few months so it all 
blurs together...
put this as /usr/local/bin/jset or something ....

    export PATH,BASEPATH
    if not exists $BASEPATH then BASEPATH=$PATH
    switch $1:
       case "openjdk":
             PATH=$BASEPATH
             break;
       case "sun":
            PATH=/path/to/sun/jdk/bin:$BASEPATH
            break;
       case "somethign else":
             PATH=/path/to/something/else:$BASEPATH
             break;
       default:
             echo "Usage:  $0 {sun|openjdk|somethingelse}"
             break
    endswitch;


this is the old school brute force method, doesn't rely on any external 
magic other than a sane initial PATH