[CentOS] java 1.6 and 1.7 on CentOS

Tue Aug 19 14:59:28 UTC 2014
Les Mikesell <lesmikesell at gmail.com>

On Tue, Aug 19, 2014 at 6:06 AM, Asma rabe <asma.rabe at gmail.com> wrote:
>
> I have java 1.7 installed on CentOS machine. when i tried to run java
> program i got an error and found that i should run it using java 1.6.
>
>
> Is the best solution to install Java 1.6 and have both java 1.6 and java
> 1.7 at same time? or is there a better solution.

Java is packaged with different names for the 1.6 and 1.7 openjdk
versions.   You can find all the relevant packages with 'yum search
java' or 'yum search openjdk'.   The corresponding -devel packages
have the compilers in case you need more than the runtime.   If all of
your java applications will run on 1.6 you can simply remove any 1.7
packages you have and make sure 1.6 is installed.

> If i should install both java 1.6 and 1.7 , how to do that ?

You can install both with yum like any other packages.  However, they
both install in odd places and use a set of double symlinks managed by
the alternatives package to put one or the other in your PATH as the
default version.   Obviously you can only have one default, but you
may in fact need to run different applications that require different
versions simultaneously - or different users on the same system may
have different requirements.    If you need to run a non-default
version, you should export JAVA_HOME=/path/to/that/installation (which
will be something obvious under ./usr/lib/jvm, but be sure you
understand the symlinks) and execute the full path to java in the bin
subdirectory of that location.   And thank RedHat for making it so
simple...

-- 
   Les Mikesell
     lesmikesell at gmail.com