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-jdkCreate 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.bckSet
PATH
andLD_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_PATHModify the
JRE_HOME
variable fromJRE_HOME=/opt/bitnami/java
toJRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64
in file/opt/bitnami/apache-tomcat/scripts/ctl.sh
Modify the
JAVA_HOME
variable fromJAVA_HOME=/opt/bitnami/java
toJAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
in both/opt/bitnami/scripts/setenv.sh
and/opt/bitnami/apache-tomcat/bin/setenv.sh
filesRestart all the Bitnami services using the
ctlscript.sh
scriptsudo /opt/bitnami/ctlscript.sh restart
Load the environment and check the Java version by running the commands below
. /opt/bitnami/scripts/setenv.sh
java -versionVisit the Apache Tomcat manager application to check the Java version currently running. You should see a "Server Information" section similar to the one below
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)?
Open Terminal from Application Dash or press Ctrl+Alt+T
Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier
sudo apt updateOptional: To search available distributions of
openjdk
, use the following command:apt search openjdk
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 codeFor
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.)For
PATH
(Environment Variable) type command as shown below, inTerminal
:export PATH=$PATH:$JAVA_HOME/bin
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
Delete Data from Arraylist with a For-Loop
What Is Shareduserid in Android, and How Is It Used
I Would Like to Set My Variables at the Top of My Class Instead of in the Method
Error: Unable to Load Installed Packages Just Now
How to Create a Directory in Java
Lambdas: Local Variables Need Final, Instance Variables Don'T
Creating a Variable Name Using a String Value
How to Read System Environment Variable in Spring Applicationcontext
Is Java.Sql.Connection Thread Safe
Opengl Es2 Alpha Test Problems
Android.Util.Androidruntimeexception: Requestfeature() Must Be Called Before Adding Content
Android Adding Simple Animations While Setvisibility(View.Gone)
Difference Between _Java_Options, Java_Tool_Options and Java_Opts
How to Handle Windows File Upload Using Selenium Webdriver