Updating Your Development Tools

It is critical to keep your development environment up to date, both to take advantage of the ever-changing technology landscape, as well as to stay ahead of adversaries who want to infiltrate your systems.  Here are some tips on updating your most important components.

Java

Today we’ll  be focusing on Debian-based Ubuntu Linux systems, used predominantly for Spring development.  For these systems, we prefer using the aptitude Advanced Packaging Tool (APT) for all software updates.

Unfortunately, standard apt repositories often don’t have the latest version of the Java toolkits.  However, others maintain their own Personal Package Archives (PPAs) that often have the software you need.  In general, you want to be weary of PPAs from untrusted sources, but webupd8team maintains a highly reputable PPA with all the latest Java products.

The process is straightforward.  First as always, update the packages already installed on your system:

$ sudo apt-get update -y
$ sudo apt-get upgrade -y

Next add the PPA to your system’s list of repositories:

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update -y

Now you can install Java.  For most Spring-based Java applications, Java8 is required.

$ sudo apt-get install oracle-java8-installer

You can confirm your new version with the -version command line option.

$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

At the time of this written, Java9 is now available from the oracle-java9-installer package.

Maven

While current version of Ubuntu (16.04) come with Maven2, you typically need Maven3 for Spring applications.  Unfortunately, there’s no known reputable PPA to retrieve it from, so we’ll just have to pull down the archive and install it manually.

First, get the latest version of Maven from https://maven.apache.org/download.cgi and store it in /usr/local of your Ubuntu system.

$ cd /usr/local
$ sudo wget http://www.gtlib.gatech.edu/pub/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

Unpack the archive and make a symbolic link to a more usable name.

$ sudo tar xzf apache-maven-3.5.0-bin.tar.gz
$ sudo ln -s apache-maven-3.5.0 apache-maven

Finally, maven works better when your environment is properly configured.

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export M2_HOME=/usr/local/apache-maven
export MAVEN_HOME=/usr/local/apache-maven
export PATH=${M2_HOME}/bin:${PATH}

You could set these up with our local ~/.bashrc file, or setup a separate script in /etc/profile.d/apache-maven.sh.

To verify your installation:

$ mvn -version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-21-generic", arch: "amd64", family: "unix"

What’s Next?

Fortunately for most Spring applications, a current version of Java and Maven is all you really need for your system.  The remaining dependencies are usually handled automatically through you project’s pom.xml file.  Keep these two tools up to date, and you’re good to go.

 

Leave a Reply

Your email address will not be published. Required fields are marked *