Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29936

Re: install multiple Java versions

Date 2014-09-08 11:25 +0100
From lipska the kat <lipskathekat@example.com>
Newsgroups comp.lang.java.programmer
Subject Re: install multiple Java versions
References <efb21ee7-215a-4ded-94b0-4f6de34092cb@googlegroups.com>
Message-ID <h4idnTpXePO2GZDJnZ2dnUVZ8qednZ2d@bt.com> (permalink)

Show all headers | View raw


On 08/09/14 10:31, marc.at.compass@gmail.com wrote:
> Hello,
>
> I need to setup a server that will contain multiple Java versions. One version is part of a Tomcat installation and will contain Java 1.7. Also I need to install a Java program that currently uses Java 1.4.2. OS will probably be Linux RHEL 6.x, however Windows 2012 might be an option as well (TBD).
> I know how to install multiple Java versions in Windows. How does this work in Linux? Can I just install Tomcat (with it's included JVM) and the JDK 1.4.2 (I read RHEL needs JDK, not JVM) separately?
>
> Then I have the config file of the application point to the Java 1.4 bin directory location. That should do it.
>
> When googling this I found some instructions about the Linux Alternative command. Makes it esay to switch between multilpe Java versions on a Linux system. But I do need both Java versions (Tomcat & Java 1.4) to be usable simultaneously, not just one.
>
> I'm not a Linux man. Is using multiple Java versions under Linux as easy as just installing them or do I need to do more?
>
> Thanks!
> Marc

The easiest way to do this on Linux based machines is as follows.

1. DO NOT USE a package manager

in /opt (or wherever) create a directory for each release

/opt/java1.4
/opt/java1.5
/opt/java1.6
/opt/java1.7

goto http://www.oracle.com/technetwork/java/javase/downloads/index.html

and choose your poison

so for 1.7 on 64bit machine you might go with
jdk-7u67-linux-x64.tar.gz

This is called a gzipped tarball in Linux speak

Put the tarball in the relevant dir in this case
/opt/java1.7

then extract the archive

something like (ottomh)

tar -xvf jdk-7u67-linux-x64.tar.gz

That's it, it's 'installed'

all you need to do is set the path and classpath for your chosen distro

so, for example I have several instances of Tomcat running
here's an example on port 80

[lipska@blackhole ~]$ sudo cat /etc/init.d/tomcat7
[sudo] password for lipska:
# chkconfig: - 71 19
# description:  Start up the Tomcat servlet engine.

JAVA_HOME=/home/lipska/java/jdk1.7.0_51
CATALINA_HOME=/opt/apache-tomcat-7.0.42
CATALINA_BASE=$CATALINA_HOME
export JAVA_HOME CATALINA_HOME CATALINA_BASE
CLASSPATH=$CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/commons-daemon.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/bin/tomcat-juli.jar
TOMCAT_USER=tomcat
TMPDIR=/var/tmp

I'm running Tomcat as a deamon in this instance and setting the version 
of Java for this instance of Tomcat, I 'installed' Java in my home 
directory as I have various different accounts for different Javas 
although this may not work for you.

There are other ways of doing it, maybe JAVA1_7_HOME or some such

You can also set the path to the interpreter if that is required.


-- 
lipska the kat - treacherous feline.
Proudly nominated for IPOTY 2014 - LIGAF
GNU/Linux user #560883 - linuxcounter.net

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

install multiple Java versions marc.at.compass@gmail.com - 2014-09-08 02:31 -0700
  Re: install multiple Java versions lipska the kat <lipskathekat@example.com> - 2014-09-08 11:25 +0100
  Re: install multiple Java versions marc.at.compass@gmail.com - 2014-09-08 04:02 -0700
  Re: install multiple Java versions Marcel Mueller <news.5.maazl@spamgourmet.org> - 2014-09-08 20:08 +0200

csiph-web