Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Build failures may occur if multiple Java versions are installed, and Maven is pointed to the incorrect version i.e. if there is a mismatch in Java versions reported by commands  mvn -V and java -version.

Info

The best way to prevent this version mismatch is to install Maven before Java 8.

Upgrading to Java 8

For OS X, the latest Oracle Java 8 SDK can be downloaded from Oracle. 

For Ubuntu, the following steps will upgrade the installation to Java 8:

Code Block
languagetext
$ sudo add-apt-repository ppa:webupd8team/java -y
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer oracle-java8-set-default -y

You will have to accept the Oracle binary license terms

 

Setting JAVA_HOME 

If not set automatically during the Java 8 installation process, The JAVA_HOME environment variable should be set to the JRE installation location for Java 8. The process for verifying/setting the proper version varies with platform.

On OS X

The current JAVA_HOME may be verified with:

Code Block
languagetext
$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

...

Code Block
languagetext
$ export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

On Ubuntu

To verify the JAVA_HOME:

Code Block
languagetext
$ sudoenv update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/| grep JAVA_HOME
JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java          1072      auto mode
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2            

If JAVA_HOME is not set or incorrect, either run or add the following to the shell profile:

Code Block
languagetext
$ export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java          1072      manual mode

Press enter to keep the current choice[*], or type selection number: 

Building API Docs

To build a local set of the ONOS Java API documentation bundle, use the onos-build-docs utility, which uses Maven to generate both internal and external documentation. 

...