javaazul-zulu

How to upgrade JDK from Oracle to Zulu in redhat linux


I want to upgrade my Linux JDK from Oracle to Azul-Zulu.can someone helps me to do this. What to do after downloading the tar.gz Zulu package? I see that after extracting the downloaded package we need to put it in the path where we need to access java. Is that correct or what we can do more like setting environment variables etc.


Solution

  • the answer to your question depends on what you actually want to start with the JDK. Sometimes is is sufficient to change the path to java binary in a start script, e.g. Eclipse or Tomcat, sometimes you also need to setup the variable JAVA_HOME.

    To setup the java for yourself only:

    Check your shell by running echo $SHELL

    -> /bin/bash
    -> /bin/zsh
    -> /bin/tcsh
    

    or something like that Locate your shell's config file:

    bash: ~/.bashrc
    zsh: ~/.zshrc
    tcsh: ~/.cshrc or ~/.tcshrc
    

    and optionally most of the shells: ~/.profile or ~/.login check those file(s) if you already have variable declarations for: JAVA_HOME JRE_HOME (and rarely seen) SDK_HOME JDK_HOME

    check whether any of those files contain a setup for the variable PATH (probably has)

    If you found any of the *_HOME variables from above you can change them to reflect your new java home directory: e.g. zulu11.37.17-ca-jdk11.0.6-linux_x64 located under /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64 would mean to set the variables as follows: zsh and bash:

    export JAVA_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
    export JRE_HOME=/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
    

    tcsh

    setenv JAVA_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
    setenv JRE_HOME /opt/zulu11.37.17-ca-jdk11.0.6-linux_x64
    

    SDK_HOME and JDK_HOME may point to the above locations as well but are normally unused.

    If you located your PATH somewhere it may read something like this: zsh and bash:

     export PATH=~/bin:$PATH
    

    tcsh:

     setenv PATH ~/bin:$PATH
    

    In order for your new java to appear "before" the "other" java you need to update (or create if missing) this to e.g.: zsh and bash:

     export PATH=~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
    

    tcsh:

     setenv PATH ~/bin:/opt/zulu11.37.17-ca-jdk11.0.6-linux_x64/bin:$PATH
    

    After completely logging out and in again your JAVA_HOME and PATH can be controlled in a shell like this:

    echo $JAVA_HOME    -> should point to *your* java folder
    echo $PATH         -> should contain *your* java folder's bin directroy
    which java         -> should list the new java binary instead of /bin/java or /usr/bin/java
    

    BTW: the variables JAVA_HOME, JRE_HOME and PATH may also be set in a startscript, e.g. catalina.sh for tomcat or the eclipse.ini for eclipse if you do not want to modify your environment.

    If you download the RPM/DEB instead of the tar.gz and install the package you (may) not need configure anything since the packages might re-configure your system for you

    Cheers, Holger