Moving from Jdk 1.7 to Jdk 1.8 on Ubuntu

How can I change Java version 1.7 to 1.8 in Ubuntu?

you can set the envirnoment variable to java 1.8
using this method
Edit the /etc/profile

    sudo gedit /etc/profile

Add these lines in the end

    JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

like mentioned in this answer

How to set Java environment path in Ubuntu

Unable to downgrade java version from 1.8 to 1.7 in ubuntu

Bitnami developer here. Please find below the steps required to install Java 7 JDK on your system and modify the Bitnami environment for changes to take effect. As an extra step before starting to modify your system, I recommend you to create a server backup.

  • Install Java 7 JDK on your system by running the commands below. It should be installed at /usr/lib/jvm/java-7-openjdk-amd64

    sudo apt-get update
    sudo apt-get install openjdk-7-jdk
  • Create a backup of the files that you need to modify

    cp /home/bitnami/.bashrc /home/bitnami/.bashrc.bck
    sudo cp /opt/bitnami/scripts/setenv.sh /opt/bitnami/scripts/setenv.sh.bck
    sudo cp /opt/bitnami/apache-tomcat/scripts/ctl.sh /opt/bitnami/apache-tomcat/scripts/ctl.sh.bck
    sudo cp /opt/bitnami/apache-tomcat/bin/setenv.sh /opt/bitnami/apache-tomcat/bin/setenv.sh.bck
  • Set PATH and LD_LIBRARY_PATH environment variables to point to the Java 7 installation directory adding the lines below at the end of the /opt/bitnami/scripts/setenv.sh file

    # Set PATH and LD_LIBRARY_PATH for Java 7
    PATH="/usr/lib/jvm/java-7-openjdk-amd64/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/java/bin:/opt/bitnami/php/bin:/opt/bitnami/mysql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:$PATH"
    export PATH
    LD_LIBRARY_PATH="/usr/lib/jvm/java-7-openjdk-amd64/lib:/opt/bitnami/sqlite/lib:/opt/bitnami/mysql/lib:/opt/bitnami/apache2/lib:/opt/bitnami/common/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH
  • Modify the JRE_HOME variable from JRE_HOME=/opt/bitnami/java to JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64 in file /opt/bitnami/apache-tomcat/scripts/ctl.sh

  • Modify the JAVA_HOME variable from JAVA_HOME=/opt/bitnami/java to JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 in both /opt/bitnami/scripts/setenv.sh and /opt/bitnami/apache-tomcat/bin/setenv.sh files

  • Restart all the Bitnami services using the ctlscript.sh script

    sudo /opt/bitnami/ctlscript.sh restart
  • Load the environment and check the Java version by running the commands below

    . /opt/bitnami/scripts/setenv.sh
    java -version
  • Visit the Apache Tomcat manager application to check the Java version currently running. You should see a "Server Information" section similar to the one below

Tomcat Manager App Server Information

Additionally, you can modify the /home/bitnami/.bashrc file for the new environment to be automatically loaded every time that you connect to your server by adding the line below to the end of the file

    . /opt/bitnami/scripts/setenv.sh

Best regards,

Gonzalo

How to install the JDK on Ubuntu Linux

Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,

How to install Open JDK (Java developement kit) in Ubuntu (Linux)?

  1. Open Terminal from Application Dash or press Ctrl+Alt+T

  2. Update repository:

    sudo add-apt-repository ppa:openjdk-r/ppa  # only Ubuntu 17.4 and earlier
    sudo apt update
  3. Optional: To search available distributions of openjdk, use the following command:

    apt search openjdk
  4. Install the appropriate version with the following command:

    sudo apt install openjdk-8-jdk
    sudo apt install openjdk-8-source #this is optional, the jdk source code
  5. For JAVA_HOME (Environment Variable) type command as shown below, in "Terminal" using your installation path...

    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk

    (Note: /usr/lib/jvm/java-8-openjdk is symbolically used here just for demostration. You should use your path as per your installation.)

  6. For PATH (Environment Variable) type command as shown below, in Terminal:

    export PATH=$PATH:$JAVA_HOME/bin

  7. To check your installation:

    java -version

Installing Java 7 on Ubuntu

This answer used to describe how to install Oracle Java 7. This no longer works since Oracle end-of-lifed Java 7 and put the binary downloads for versions with security patches behind a paywall. Also, OpenJDK has grown up and is a more viable alternative nowadays.

In Ubuntu 16.04 and higher, Java 7 is no longer available. Usually you're best off installing Java 8 (or 9) instead.

sudo apt-get install openjdk-8-jre

or, f you also want the compiler, get the jdk:

sudo apt-get install openjdk-8-jdk

In Trusty, the easiest way to install Java 7 currently is to install OpenJDK package:

sudo apt-get install openjdk-7-jre

or, for the jdk:

sudo apt-get install openjdk-7-jdk

If you are specifically looking for Java 7 on a version of Ubuntu that no longer supports it, see https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher .



Related Topics



Leave a reply



Submit