Some distributions, such as Linux Mint, have OpenJDK installed right out of the box. For Ubuntu Linux, however, if we are to run applications programmed in Java, we need to install Java. In this guide, we will install Java on Ubuntu using both OpenJDK, and the official OracleJDK.
Unblock any international website, browse anonymously, and movies and Mp3 with complete safety with CyberGhost, just for $2.75 per month:
We have prepared this guide on Ubuntu Linux 15.04 and Linux Mint 17.2. It should work to install Java in recent earlier and future versions. It might also work for Linux distributions based on Ubuntu/Debian.
What's the difference between OpenJDK and OracleJDK? 85c26
There are two options to install Java on Linux: The open-source OpenJDK and the official OracleJDK.
Is there a difference between the two? Which one should we pick, and why?
The fact is, there are no huge differences between OracleJDK and OpenJDK, they are very close.
As answered on the Chromium and Google Chrome.
For most Java applications, OpenJDK is good enough. After all, it is maintained by Oracle engineers, so it is in no way an "inferior" type of Java. If we don't need the third-party components of OracleJDK, like JRockit Mission Control, OpenJDK is perfectly adequate.
If OpenJDK doesn't work with a Java application, we should install OracleJDK.
Do we already have Java installed? 2o2uj
If we are using a distribution based on Ubuntu, it might already have OpenJDK installed, like Linux Mint does.
To check that, we just need to open a terminal with Ctrl+Alt+T and type:
java -version
If Java is already installed, we will get the current version.
If it isn't, on some distributions we will get a list of packages that include Java.
How to install Java in Ubuntu with openJDK 435n6w
To install Java with OpenJDK on Ubuntu, we open a terminal and type:
sudo apt-get install openjdk-8-jre -y
This command will install the Java Runtime Environment (JRE) and should be enough for most s.
If you are new to Linux, that when we are asked to enter our on the terminal, for the sudo command, nothing will appear as we are typing, no stars or dots or anything. We just type our and press Enter.
The current version of Java, as of this writing, is version 8, that is why we are are using openjdk-8-jre.
When Java reaches version 9, which is expected on September 22, 2016, the same command will work with openjdk-9-jre.
After we install Java, the "java -version" command will return the proper version.
Install Java to compile 5g2lh
To compile Java applications, we need to install the Java Development Kit (JDK).
This is essential if we are writing code in Java or want to use certain applications such as Apache Ant, Apache Maven, Eclipse, IntelliJ IDEA, etc.
The command for the Java Development Kit is:
sudo apt-get install openjdk-8-jdk -y
After September 22, 2016, we can replace the command with openjdk-9-jdk to get the Java 9 Development Kit.
How to install Java in Linux Mint or Ubuntu with OracleJDK n5b43
To install Java using the OracleJDK, we first need to install Python Software Properties, with:
sudo apt-get install python-software-properties -y
Then, we add the special java repository that is maintained by the Webupd8 team.
sudo add-apt-repository ppa:webupd8team/java -y
Any time we add a repository, we then have to do an update, so the new packages are available for installation.
sudo apt-get update
Finally, we install Java with:
sudo apt-get install oracle-java8-installer -y
The installation will ask us to read the Java license at http://java.com/license.
We must agree with the Oracle Binary Code license , or the installation won't proceed.
The rest of the installation is automatic. The installer will 173MB...
...and complete the installation.
How to set the "JAVA_HOME" environment variable 713q3j
Some applications need to know the path where Java is installed, using the JAVA_HOME environment variable, which is not automatically created when we install Java.
To create this variable, we will first need to find the path of installation with the command:
sudo update-alternatives --config java
If we installed the OpenJDK, it will probably be
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
For the OracleJDK it will probably be
/usr/lib/jvm/java-8-oracle/jre/bin/java
We can copy the path by selecting it with the mouse and right-click -> copy, or pressing Ctrl+Shift+C (the plain Ctrl+C won't work on the Linux Terminal).
Then, we open the file /etc/environment with gedit:
sudo gedit /etc/environment
Don't worry about the IBUS-WARNING, it shows every time we run gedit through the terminal as root.
At the end of the file, we add the following line, containing our Java installation path we just copied:
JAVA_HOME="[our path]"
We save the file and close gedit. Then, we reload the environment file, with:
source /etc/environment
To test if everything went well, we run:
echo $JAVA_HOME
This should show our Java installation path.
, the Linux terminal is case sensitive, java_home or Java_Home won't work.
Did you have any trouble to install Java on Linux Mint or Ubuntu? 10218
If anything on this guide didn't work for you as described, and you couldn't install Java on Linux Mint or Ubuntu, leave us a comment.
PCsteps 4y3t4m
Do you want to PCsteps, so we can post high quality articles throughout the week?
You can like our Newegg.
If you prefer your purchases from China, we are d with the largest international e-shops: