[Java] Install/uninstall Oracle/Open JDK, Maven, Ant, Tomcat on Ubuntu14.04

[Java] Install/uninstall Oracle/Open JDK, Maven, Ant, Tomcat on Ubuntu14.04

I used the following command to install Java tools on Ubuntu14.04 , and it also works for old Ubuntu version.

Install Oracle JDK6, JDK7, JDK8

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java6-installer

or

$ sudo apt-get install oracle-java7-installer

or 

$ sudo apt-get install oracle-java8-installer

Install default JRE/JDK
This is the recommended and easiest option. This will install OpenJDK 6 on Ubuntu 12.04 and earlier. And it will install OpenJDK 7 on 12.10+.

$ sudo apt-get update
$ sudo apt-get install default-jre

If you need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA), please execute the following command:

$ sudo apt-get install default-jdk

Install OpenJDK 8
OpenJDK 8 was released in March 2014. It’s available in Ubuntu Software Center only for Ubuntu 14.10 and Ubuntu 15.04. If you want to install OpenJDK 8 on Ubuntu14.04, you can install it from a PPA repository:

$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update 
$ sudo apt-get install openjdk-8-jre

or

$ sudo apt-get install openjdk-8-jdk

If you have more than one version JVM installed on your Ubuntu, execute below command setting the default Java:

$ sudo update-alternatives --config java
$ java -version

And type in a number to select a Java version.

Uninstall OpenJDK
If you want to uninstall OpenJDK, you can use the following command:

$ sudo apt-get purge openjdk*

Install Maven

$ sudo apt-get install maven
$ mvn -version

Install tomcat7

$ sudo apt-get install tomcat7

Install ant

$ sudo apt-get install ant

If you are mission add-apt-repository command, execute the following command:

$ sudo apt-get install software-properties-common python-software-properties
(Visited 162 time, 1 visit today)
Facebooktwittergoogle_plusredditpinterestlinkedinmail
Comments are closed.