This discussion is archived
4 Replies Latest reply: Mar 5, 2010 12:54 PM by 843804 RSS

Installing Java on Suse with existing installation

843804 Newbie
Currently Being Moderated
Hello All,

I'm rather a newbie when installing Java on a (Suse) Linux system. I downloaded both the
jdk-1_5_0_05-linux-i586.bin
and
jdk-1_5_0_05-linux-i586-rpm.bin
files and installed them.

The first one had no noticable effect. In the end I copied he rpm to my /usr/lib/jvm directory and installed the rpm.

The result is that I have the following contents in the /usr/lib/jvm directory:
rwxr-xr-x 6 root root 424 2005-10-02 11:03 .
drwxr-xr-x 108 root root 34168 2005-10-02 11:03 ..
lrwxrwxrwx 1 root root 26 2005-10-02 11:03 java -> /etc/alternatives/java_sdk
lrwxrwxrwx 1 root root 32 2005-10-02 11:03 java-1.4.2 -> /etc/alternatives/java_sdk_1.4.2
lrwxrwxrwx 1 root root 23 2005-10-02 11:03 java-1.4.2-sun -> java-1.4.2-sun-1.4.2.05
drwxr-xr-x 6 root root 144 2005-10-02 11:03 java-1.4.2-sun-1.4.2.05
drwxr-xr-x 3 root root 72 2005-06-24 13:04 java-1.4.2-sun-1.4.2.06
drwxr-xr-x 3 root root 72 2005-10-02 10:46 java-1.4.2-sun-1.4.2.08
lrwxrwxrwx 1 root root 30 2005-10-02 11:03 java-sun -> /etc/alternatives/java_sdk_sun
drwxr-xr-x 9 root root 376 2005-08-27 03:34 jdk1.5.0_05
lrwxrwxrwx 1 root root 21 2005-10-02 11:01 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 2005-10-02 11:01 jre-1.4.2 -> /etc/alternatives/jre_1.4.2
lrwxrwxrwx 1 root root 27 2005-10-02 11:01 jre-1.4.2-sun -> java-1.4.2-sun-1.4.2.05/jre
lrwxrwxrwx 1 root root 25 2005-10-02 11:01 jre-sun -> /etc/alternatives/jre_sun

The JDK 1.5 is installed, but the links are not changed. Even the java from the bin directory is linked to the java of the 1.4 jre:
~> ls -la /usr/lib/jvm/jdk1.5.0_05/bin/java
lrwxrwxrwx 1 root root 22 2005-10-02 11:10 /usr/lib/jvm/jdk1.5.0_05/bin/java -> /etc/alternatives/java
~> ls -la /etc/alternatives/java
lrwxrwxrwx 1 root root 35 2005-10-02 11:01 /etc/alternatives/java -> /usr/lib/jvm/jre-1.4.2-sun/bin/java

What do I need to do to change the links? What do I need to do to change all (probably hidden) links all over my system?

Tia,
Michel
  • 1. Java Environment on SuSE 9.x and 10.0
    843804 Newbie
    Currently Being Moderated
    To set up its default Java environment, SuSE uses a combination of symbolic links and a script called /etc/profile.d/alljava.sh. This can be a real hassle if you want to set up your own JDK. Anyway, this is what I did to set up mine:

    * I installed my JDK to /usr/local/jdk1.5.0_05

    * Under version 9.x, it was possible to replace the SuSE-created java symbolic link in /usr/lib by using something like ln -s/usr/local/jdk1.5.0_05 java. After logging out and back in, the alljava.sh script will use this symbolic to set up all the necessary environment variables. But, alljava.sh has changed between versions 9.x and 10.0 (The two versions are at the end of this post if anyone is interested).

    * Deleted any java* symbolic links under /etc/bin

    * I'm using version 10.0 and I gave up struggling with alljava.sh, so in my .profile file I just unset everything done by alljava.sh, and set my own:
    unset JDK_HOME
    unset JAVA_BINDIR
    unset JAVA_HOME
    unset JRE_HOME
    unset SDK_HOME
    unset JAVA_ROOT
    
    export JAVA_HOME=/usr/local/jdk1.5.0_05
    export PATH=$PATH:$JAVA_HOME/bin:.:
    I'm sure there's a more elegant way of doing this, but eventually you have to get down and do some work rather than battling with your tools.


    alljava.sh version 9.x
    #                                                                               
    #    /etc/profile.d/alljava.sh                                                    
    #                                                                               
    # send feedback to http://www.suse.de/feedback
    
    #
    # This script sets some environment variables for default java.
    # Affected variables: PATH, JAVA_BINDIR, JAVA_HOME, JRE_HOME, 
    #                     JDK_HOME, SDK_HOME
    #
    
    if [ -x /usr/lib/java/bin/java ] || [ -x /usr/lib/java/bin/jre ] ; then
      export PATH=$PATH:/usr/lib/java/bin
      export JAVA_BINDIR=/usr/lib/java/bin
      export JAVA_ROOT=/usr/lib/java
      export JAVA_HOME=/usr/lib/java
      if [ -x /usr/lib/java/jre/bin/java ] ; then
        export JRE_HOME=/usr/lib/java/jre
      else
        export JRE_HOME=/usr/lib/java
      fi        
      unset JDK_HOME
      unset SDK_HOME
      if [ -x /usr/lib/java/bin/javac ] ; then
        # it is development kit 
        if [ -x /usr/lib/java/bin/jre ] ; then
          export JDK_HOME=/usr/lib/java
        else
          export JDK_HOME=/usr/lib/java
          export SDK_HOME=/usr/lib/java
        fi
      fi
    else
      if [ -x /usr/lib/java/jre/bin/java ] ; then
        # it is IBMJava2-JRE or SunJava2-JRE
        export PATH=$PATH:/usr/lib/java/jre/bin
        export JAVA_BINDIR=/usr/lib/java/jre/bin
        export JAVA_ROOT=/usr/lib/java
        export JAVA_HOME=/usr/lib/java/jre
        export JRE_HOME=/usr/lib/java/jre
        unset JDK_HOME
        unset SDK_HOME
      fi
    fi
    alljava.sh version 10.0
    #
    #    /etc/profile.d/alljava.sh
    #
    # send feedback to http://www.suse.de/feedback
    
    #
    # This script sets some environment variables for default java.
    # Affected variables: PATH, JAVA_BINDIR, JAVA_HOME, JRE_HOME,
    #                     JDK_HOME, SDK_HOME
    #
    
    __libdir=lib
    if [ -x /usr/lib64/jvm/java ] || [ -x /usr/lib64/jvm/jre ] ; then
      __libdir=lib64
    fi
    
    if [ -x /usr/$__libdir/jvm/java/bin/java ] || [ -x /usr/$__libdir/jvm/java/bin/jre ] ; then
      export JAVA_BINDIR=/usr/$__libdir/jvm/java/bin
      export JAVA_ROOT=/usr/$__libdir/jvm/java
      export JAVA_HOME=/usr/$__libdir/jvm/java
      if [ -x /usr/$__libdir/jvm/java/jre/bin/java ] ; then
        export JRE_HOME=/usr/$__libdir/jvm/java/jre
      else
        export JRE_HOME=/usr/$__libdir/jvm/java
      fi
      unset JDK_HOME
      unset SDK_HOME
      if [ -x /usr/$__libdir/jvm/java/bin/javac ] ; then
        # it is development kit
        if [ -x /usr/$__libdir/jvm/java/bin/jre ] ; then
          export JDK_HOME=/usr/$__libdir/jvm/java
        else
          export JDK_HOME=/usr/$__libdir/jvm/java
          export SDK_HOME=/usr/$__libdir/jvm/java
        fi
      fi
    else
      if [ -x /usr/$__libdir/jvm/jre/bin/java ] ; then
        # it is IBMJava2-JRE or SunJava2-JRE
        export PATH=$PATH:/usr/$__libdir/jvm/jre/bin
        export JAVA_BINDIR=/usr/$__libdir/jvm/jre/bin
        export JAVA_ROOT=/usr/$__libdir/jvm/jre
        export JAVA_HOME=/usr/$__libdir/jvm/jre
        export JRE_HOME=/usr/$__libdir/jvm/jre
        unset JDK_HOME
        unset SDK_HOME
      fi
    fi
    
    unset __libdir
  • 2. Re: Java Environment on SuSE 9.x and 10.0
    843804 Newbie
    Currently Being Moderated
    I would like to set up my java environment in Suse 10.0, but I was not successful in following such explanation. After changing .profile and opening a new shell, typing java command does not give any results, this command was not found.

    I using jdk-1_5_0_06-linux-i586.bin.

    Thanks
  • 3. Re: Java Environment on SuSE 9.x and 10.0
    843804 Newbie
    Currently Being Moderated
    Trying logging off and back on again. This should do the trick.
  • 4. Re: Java Environment on SuSE 9.x and 10.0
    843804 Newbie
    Currently Being Moderated
    Noticed the following in my install

    alljava.sh: export JRE_HOME=/usr/$_libdir/jvm/jre

    I change it to $__libdir (double underscore)

    and that fixed it.