[ubuntu-in] Is it possible to run openjdk and java side by side on linux

James Sebastian james.sebastian at gmail.com
Sat Jul 18 05:53:39 UTC 2015


I could reply in detail earlier.
Apart from co-existing version sof Oracle JDK and Open JDK, you can  have
different versions of Java (JDK/JRE) installed in same system as well. Say
Open JDK 6,7 along with Oracle JDK 6 & 7.

Like asusming a 64 bit system
openjdk-6-jdk:amd64
openjdk-6-jdk:i386
openjdk-7-jdk:amd64
openjdk-7-jdk:i386

Then you would be able to install Oracle Java  by installing packages like

 oracle-java7-installer
 oracle-java7-installer

all the above using standard package installing utilities.

Then you can extra tar balls/.bin files to a given directory and set
Java_HOME or setting Java paths in different applications to make use.
So in short it is possible to have tons different java versions
simutaneously running in a system

Then using the configuration parameters in the application which uses Java
you need to set which version of Java to use.

For eg: For our application, we use Tomcat. There it looks for a certain
directories in their order and chooses the first one. So I can  change/add
the first directory to the one  I need for tomcat to pickup JDK and
JAVA_HOME I like.

That goes like this for tomcat

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/default-java ${OPENJDKS} /usr/lib/jvm/java-6-openjdk
/usr
/lib/jvm/java-6-sun /usr/lib/jvm/java-7-oracle"

# Look for the right JVM to use
for jdir in $JDK_DIRS; do
    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
    JAVA_HOME="$jdir"
    fi
done
export JAVA_HOME
\

But each reasonable application will have a way to set Java Home or JDK
other than system default (set by /etc/alternatives), user default (which
can be setup in .profile or similar files). That would be the place you
need to look for when you need one Java version for one application and
another for another application. Or when you need to switch between
different java applications

Trust this helps

On 18 July 2015 at 10:36, Ramnarayan.K <ramnarayan.k at gmail.com> wrote:

> "Subhadip Ghosh" wrote:
>
> > I suppose you actually meant Oracle JDK/JRE when you said java. It's
> possible to have OpenJDK and Oracle JDK installed on the same system but
> you can have only one set as default at any point of time for obvious
> reason.
>
> Apologies
> You are correct
> Ram
>
> --
> ubuntu-in mailing list
> ubuntu-in at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-in
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-in/attachments/20150718/90658772/attachment.html>


More information about the ubuntu-in mailing list