On Aug 26, 2005, at 11:35 AM, Shawn Erickson wrote:
I personally use a bash with .bashrc containing a set of functions
to assist in setting up shell as I need. The following is an
example. I guess I could clean things up a little more and make
them available if folks want them (generally crude but functional,
not a bash "power" script writer).
The following link will list a .bashrc file that can be used to add
shell functions "listJava", "setJava" and "unsetJava" to a shell
running bash. It also includes a custom command prompt that you may
or may not like. Bugs, etc. likely exist so use at your own risk.
Also please feel free to suggest fixes, enhancements, etc.
"listJava" will list the currently available JVMs on the system as
well as the currently active version of Java if you type "java" at
the prompt.
For example...
[G5::~]
> listJava
Available JVMs: 1.3 1.3.1 1.4 1.4.2 1.5 1.5.0
Current Java:
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-215)
Java HotSpot(TM) Client VM (build 1.4.2-50, mixed mode)
[G5::~]
>
"setJava" will set the shell environment up (just for that shell
instance) to the JVM you desire. After using this function all future
uses of java, javac, etc. in the shell use run the JVM version you
requested. The value you supply to setJava has to be one of the ones
listed by listJava.
For example...
[G5::~]
> setJava 1.5
Configuring Shell Environment for Java 1.5
Current Java:
HotSpot not at correct virtual address. Sharing disabled.
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-56)
Java HotSpot(TM) Client VM (build 1.5.0_02-36, mixed mode)
[G5:J1.5:~]
>
"unsetJava" will unset things taking the shell environment back to
the default JVM (as defined by sym-links under JavaVM.framework, ones
that you should need to modify).
For example...
[G5:J1.5:~]
> unsetJava
Configuring Shell Environment for default Java
Current Java:
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-215)
Java HotSpot(TM) Client VM (build 1.4.2-50, mixed mode)
[G5::~]
>
It is important to understand that the setJava and unsetJava function
only affects which version of java, javac, etc. will get used for
that particular instance of the shell (terminal window). It doesn't
affect the system globally. It doesn't affect what version of Java a
plist based Java application will use or what version Xcode, Intellji
IDEA, etc. will use for a given project (or itself).
It doesn't muck with symbolic links, etc. It only configures PATH and
JAVA_HOME as needed.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden