[CentOS] java 1.6 and 1.7 on CentOS

Tue Aug 19 19:48:21 UTC 2014
Les Mikesell <lesmikesell at gmail.com>

On Tue, Aug 19, 2014 at 2:25 PM, John R Pierce <pierce at hogranch.com> wrote:
> On 8/19/2014 12:08 PM, Les Mikesell wrote:
>> Yes, I think pretty much everything in recent Linux distributions is
>> aimed at making it more single-user and PC-like instead of a unix
>> server.  Following Apple's lead, I guess. But even a single user may
>> need to run applications with differing requirements. Fortunately you
>> can still set JAVA_HOME and give a full path to either executable -
>> you just have to follow the weird symlinks or list the paths from the
>> rpm to figure out where they really put things.
>
> setting JAVA_HOME generally isn't required for running java at the
> shell, just putting the right java bin directory first in the path is
> sufficient...
>
> when you invoke java, it sets JAVA_HOME itself if its not already set.
>
> and, WOW, what a tangled web of symlinks.
>
> export
> JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el7_0.x86_64/jre
> export PATH=$JAVA_HOME/bin:$PATH
>
> is the REAL java directory...  but that will change with a minor
> update.   yuck!!!
>

You usually end up with a symlink like /usr/java/latest pointing to a
versioned directory even if you install your own from Oracle, but with
just half of the mess and you know where the real thing is.

If you just execute java and it just runs a single app you can get
away without setting JAVA_HOME.   But if you do something like
executing ant (which starts as a shell script that tries to find java
for you, or some more complex thing that is going to need javac and
friends) you are better off setting it to where you want it.

-- 
   Les Mikesell
     lesmikesell at gmail.com