[CentOS-docs] Suggestion for "how to" section: easy way to install the JDK?

Sat Oct 9 07:32:19 UTC 2010
Manuel Wolfshant <wolfy at nobugconsulting.ro>

On 10/09/2010 04:33 AM, Milos Blazevic wrote:
> Bob Stine wrote:
>   
>> Milos Blazivec wrote:
>>
>>     /... I am, in fact, interested in making adjustments to the Wiki /
>>     /page - but sadly not the ones you proposed Bob, since the just
>>     won't do /
>>     /the trick./
>>
>>
>> Hmm.  I ran the executed the bin file, edited /etc/profile so that 
>> PATH included the "bin" directory of the sun jdk directory, added 
>> environment variable JDK_HOME,  deleted the /usr/bin/java symlink from 
>> java -> /etc/alternative/java, and everything works, or at least well 
>> enough for me to run the Eclipse C++ IDE, which was my goal.  
>>
>> Maybe adding the jdk was unnecessary for Eclipse to work?
>>
>> Could you unpack "just won't do", or point to a discussion of the issue?
>>
>>     
> What I meant is that the instructions you suggested in your first e-mail 
> are taken from: 
> http://www.oracle.com/technetwork/java/javase/install-linux-64-rpm-138254.html
> and are all but comprehenssive, let alone appropriate for beginners. 
> These installation instructions have been accompanying Sun Java as long 
> as I can remember, and "strangely", no one cared to mention 'em in the 
> Wiki page... don't you think that's kinda odd? I don't - 'cause they 
> don't work!
>
> This second part (editing /etc/profiles, deleting symlinks and editing 
> PATH...) is NOT what you mentioned in your first e-mail. However, in my 
> honest oppinion, this is still not the correct way to do this.
>
> What you did, is that you probably got it to work for Your particular 
> purpose by resorting to an unconventional method (i.e. circumvent the 
> mechanism intended for this purpose, rather than a by-the-book 
> approach). By solving the problem this way, sooner or later you'll end 
> up breaking something. Maintainance may prove difficult later
>
> For me, by-the-book is using "alternatives" utility for this purpose - 
> intended by the makers way to handle this kind of issues. (switching 
> between different mail servers, etc.)
>   

  Using alternatives in the context of Java is 100% useless for ordinary 
users who do not want to use the stock gcj or openjdk packages ( and 
therefore replace them with Sun's packages). As far as I have seen on 
the few hundreds workstations that I maintain + the requests in the IRC 
channel, users only need to run
- browser java plugin  ( solved by installing Sun's jre + a convenient 
ln -s already mentioned before in this thread
- java ( the binary, as in " java -Xmx400m -DuseDesktop=true 
-Dsun.java2d.pmoffscreen=false -jar /usr/share/jalbum/JAlbum.jar  ") in 
order to run .jar applications
- the libs needed by Eclipse, also mentioned before in the thread
> Better idea is to adjust symlink to point to the desired binary, rather 
> than editing PATH variable, deleting the symlink,...
>   

At least the jre package (and I am almost sure jdk too) from Sun comes 
with the following structure:
lrwxrwxrwx 1 root root   16 Apr 10 01:25 default -> /usr/java/latest
drwxr-xr-x 7 root root 4096 Jun 28 23:34 jre1.6.0_20
lrwxrwxrwx 1 root root   21 Jun 28 23:35 latest -> /usr/java/jre1.6.0_20

Using /usr/java/latest and / or /usr/java/default in your scripts makes 
them immune to upgrades, as long as you stick with Sun's packages ( 
which - sad but true - make the java-openjdk / gcj packages useless and 
offer ( for the moment ) better compatibility with the real world. At 
least from I where I stand.