spikesource hints'n'tips

Our Top Tags

                                       

Mailing List

Keep uptodate with the latest hints'n' tips as they are published by signing up to our mailing list.

Our RSS Feeds








Latest Linux News

Hosted Zimbra Email Catches On With Managed Service Providers

Saturday, 19 July 2008
MSPmentor: "When it comes to hosted email, why zig when you can zag? That explains the strategy at EtomicMail, a managed service provider that’s hosting Zimbra — an open source email platf

An Open Source Seeing Eye Dog for Web Surfers

Saturday, 19 July 2008
LinuxInsider: "WebAnywhere is an open source, Web-based application that acts as a screen reader of sorts for blind people. Its developer, a student at the University of Washington, designed it so tha

Perl and Bash Versions Of Binary To Decimal Conversion Script

Saturday, 19 July 2008
The Linux and Unix Menagerie: "As promised, in yesterday's post on converting binary values to decimal in C, today we're going to follow up with straight-up ports to Perl and shell. Actually, they'll

E4X: JavaScript on Steroids

Saturday, 19 July 2008
IBM Developerworks: "E4X is designed to simplify the task of writing JavaScript code for XML. It is an efficient, powerful tool that you can use to interact with XML nodes and attributes. The primary

Linux 2.6.26 Kernel Benchmarks

Saturday, 19 July 2008
Phoronix: "Over the weekend the Linux 2.6.26 kernel was released. This quarterly update to the Linux kernel introduced Kernel-based Virtual Machine improvements, new One Laptop Per Child support, a ne

Latest Digg Entries

Handling different Java runtimes on a single machine

posted Thursday, 14 September 2006

There are times when you may want to maintain different Java virtual machines on a single Linux box.  For example, you may want to test against a certain version without having to touch an already working version.

There are a few techniques for doing this.  Sun will install all the Java virtuals machine in to the /usr/java/ directory, with the directory for the specific JVM labelled as the version number.  For example  /usr/java/jdk1.5.0_08/.

You could create a symbolic link to this directory and have /usr/java/current/ always point to the JVM you want to use.

% cd /usr/java/
% ln -s jdk1.5.0_08 current
% /usr/java/current/bin/java -version

In all your scripts you can then refer to /usr/java/current/ and update the symbolic link accordingly.

Another method is to use the well known JAVA_HOME variable.  You can create a small file in /etc/profile.d/ called say java.sh (make it executable chmod a+x /etc/profile.d/java.sh) that will automatically set this everytime you open up a new shell.
#!/bin/sh
export JAVA_HOME=/usr/java/jdk1.5.0_08

You can then use the $JAVA_HOME variable in your start up scripts.  Nothing is stopping you from utilising a combination of the both techniques at once.  Create the JAVA_HOME variable to /usr/java/current/ and then all you do to change between different JVMs is update the symbolic reference.

Whatever technique you use, you should try to resist the urge to hardcode the path to the JVM in any of your start up scripts. 

tags:    

links: digg this    del.icio.us    technorati    




Related Posts

How to convert a string to upper or lower case in bash?

Monday, 2 October 2006 2:46 P GMT
How to convert a string to upper or lower case in bash?

How can I start a Java process and retain its process id?

Monday, 2 October 2006 2:41 P GMT
How can I start a Java process and retain its process id?

Using Fetchmail to forward email

Monday, 2 October 2006 2:29 P GMT
Fetchmail is a remote-mail retrieval and forwarding utility. This article describes how it can be set up to forward emails from a particular folder to another mailbox.

Handling different Java runtimes on a single machine

Thursday, 14 September 2006 10:48 A GMT
This entry takes a quick look at how you can best utilise different Java JVMs on the linux using a couple of techniques.

How to stop /etc/resolv.conf from being changed by DHCP?

Thursday, 7 September 2006 3:55 P GMT
Show how to keep /etc/resolv.conf unchanged when using DHCP.

How do can I tell if my network is receiving/sending multicast packets?

Tuesday, 5 September 2006 2:51 P GMT
If you are coding a multicast network application and want to make sure you are receiving muticast udp packets you can use the tcpdump linux utility. This entry shows you how.

How to clear shell command path cache?

Tuesday, 5 September 2006 1:57 P GMT
Way to clear the cached paths for various commands on bourne-like shells.

Detecting to see if a mail server is still alive using a simple shell script

Thursday, 31 August 2006 2:05 P GMT
This entry looks at using the Linux utility, nc, for determining if a given mail server is alive. You can easily adapt it for other servers.

How do I create a file of any given size on Linux?

Wednesday, 30 August 2006 2:52 P GMT
Using the dd command it is possible to create files of arbitrary lengths.

Installing RealPlayer and video codecs on Ubuntu

Wednesday, 30 August 2006 2:43 P GMT
Explain how you install RealPlayer under Ubuntu.

Does your cron script run in a bash shell, but not while running under crontab?

Tuesday, 22 August 2006 7:28 A GMT
This article explains why some scripts run correctly from a bash shell, but behave differently running from the crontab.

How do I get the canonical path for a symlink target?

Monday, 21 August 2006 1:01 P GMT
Getting canonical path for a symlink in Linux

Invoking Jetty as an embedded server

Wednesday, 16 August 2006 2:24 P GMT
Ever wondered how to invoke Jetty as an embedded server? David Yu from the Jetty Mailing list recently posted a way you can do this.

How to find out what application is using your port

Thursday, 15 September 2005 8:00 A GMT
How to find out what application is using your port

Use Samba to Map a Linux Directory to a Windows Drive

Tuesday, 13 September 2005 4:03 P GMT
Samba is used for sharing source code and software binary between windows and linux in Windows test uploading support project.

How to install JMeter and use it for testing

Sunday, 11 September 2005 8:00 A GMT
Apache JMeter is a 100% pure Java desktop application designed to test performance on static/dynamic resources such as static files, Servlets, CGI scripts. JMeter can also be used to regression test application by creating test scripts.

Introduction to JVM crashes

Friday, 9 September 2005 10:33 A GMT
Things to look for when checking a JVM crash

Configuring JGroups to avoid using multicasting

Wednesday, 31 August 2005 7:54 A GMT
JGroups - the cluster library used by Jboss, uses multicasting for cluster communication. This article discusses configuration of JGroups so that it does not use multi casting.

Listing open files in linux / unix system

Thursday, 25 August 2005 6:06 P GMT
If you are working in a unix system, sometime it is not obvious if a file is being opened by some other processes or not. You can get a list of all open files by using lsof command.

How do I make sure my script isn't already running before it attempts to run again?

Thursday, 18 August 2005 7:17 P GMT
How do I make sure my script isn't already running before it attempts to run again?

How to import a certificate from file in Java using keytool

Wednesday, 17 August 2005 4:56 P GMT
How to import a certificate from file in Java using keytool

CEO Kim Polese interviewed by SearchEnterpriseLinux

Wednesday, 29 June 2005 1:12 P GMT
In this SearchEnterpriseLinux.com interview, she talks about how companies are leveraging the open source model to enhance their bottom lines.