Child pages
  • Open JDK
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Table of Contents

Introduction

This page is based on experience of setting up Java 8 on Ubuntu 14.04.  Much of it may be applicable to other Java versions and distros.

Architecture

First we check which architecture we are running on.
Open a terminal and type the command arch.
The output could be i686 or i386 for a 32 bits system or x86_64 for a 64 bits system.

Environment

Your environment could already have an installation or not.

Open a terminal and run the following command :

user@machine:~$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)

In the previous output we can see that the command has been successfully executed. It gives us the default version.

Then run the following command :

user@machine:~$ update-java-alternatives -l
java-1.6.0-openjdk-i386 1061 /usr/lib/jvm/java-1.6.0-openjdk-i386
java-1.7.0-openjdk-i386 1071 /usr/lib/jvm/java-1.7.0-openjdk-i386
java-1.8.0-openjdk-i386 1069 /usr/lib/jvm/java-1.8.0-openjdk-i386
java-8-openjdk-i386 1069 /usr/lib/jvm/java-8-openjdk-i386


The current installation shows that several JVM are installed.

Installation

Run the following command in order to install or update the Open JDK 8. The idea is applicable to others JVM.

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

if you have more than one Java versions installed on your system. Run the following command and select the desired one.

user@machine:~$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                           Priority   Status
------------------------------------------------------------
0            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      manual mode
* 3            /usr/lib/jvm/java-8-openjdk-i386/jre/bin/java   1069      manual mode
Press enter to keep the current choice[*], or type selection number:

Set the default Java Compiler by running:

sudo update-alternatives --config javac

However this first part doesn't solve all the default tools to use the desired JVM.

The following command shows you if the tools use the JVM you want :

user@machine:~$ update-alternatives --get-selections | grep java
appletviewer                manual   /usr/lib/jvm/java-8-openjdk-i386/bin/appletviewer
extcheck                       manual   /usr/lib/jvm/java-8-openjdk-i386/bin/extcheck
idlj                                  manual   /usr/lib/jvm/java-8-openjdk-i386/bin/idlj
itweb-settings               auto     /usr/lib/jvm/java-6-openjdk-i386/jre/bin/itweb-settings
jar                                   manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jar
jarsigner                      manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jarsigner
java                           manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/java
javac                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/javac
javadoc                        manual   /usr/lib/jvm/java-8-openjdk-i386/bin/javadoc
javah                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/javah
javap                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/javap
javaws                         auto     /usr/lib/jvm/java-6-openjdk-i386/jre/bin/javaws
jcmd                           manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jcmd
jconsole                       manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jconsole
jdb                            manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jdb
jdeps                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jdeps
jexec                          manual   /usr/lib/jvm/java-8-openjdk-i386/jre/lib/jexec
jhat                           manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jhat
jinfo                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jinfo
jjs                            manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/jjs
jmap                           manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jmap
jps                            manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jps
jrunscript                     manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jrunscript
jsadebugd                      manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jsadebugd
jstack                         manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jstack
jstat                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jstat
jstatd                         manual   /usr/lib/jvm/java-8-openjdk-i386/bin/jstatd
keytool                        manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/keytool
lucli                          auto     /usr/lib/liblucene2-java/lucli
mozilla-javaplugin.so          manual   /usr/lib/jvm/java-8-openjdk-i386/jre/lib/i386/IcedTeaPlugin.so
native2ascii                   manual   /usr/lib/jvm/java-8-openjdk-i386/bin/native2ascii
orbd                           manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/orbd
pack200                        manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/pack200
policytool                     manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/policytool
rmic                           manual   /usr/lib/jvm/java-8-openjdk-i386/bin/rmic
rmid                           manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/rmid
rmiregistry                    manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/rmiregistry
schemagen                      manual   /usr/lib/jvm/java-8-openjdk-i386/bin/schemagen
serialver                      manual   /usr/lib/jvm/java-8-openjdk-i386/bin/serialver
servertool                     manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/servertool
tnameserv                      manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/tnameserv
unpack200                      manual   /usr/lib/jvm/java-8-openjdk-i386/jre/bin/unpack200
wsgen                          manual   /usr/lib/jvm/java-8-openjdk-i386/bin/wsgen
wsimport                       manual   /usr/lib/jvm/java-8-openjdk-i386/bin/wsimport
xjc                            manual   /usr/lib/jvm/java-8-openjdk-i386/bin/xjc
user@machine:~

if the tools are not using the needed JVM some extra step are required:

Run the following command :

sudo update-java-alternatives -s java-8-openjdk-i386

This command update the dependencies but can also complain about some missing components.

update-alternatives: error: no alternatives for mozilla-javaplugin.so. 
update
-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-8-openjdk-i386/jre/lib/i386/IcedTeaPlugin.so

In this example the Mozilla plugin is missing. This is not a big problem if you don't want to use for security reason.

In case you want to install it, here is the procedure to get it. At the time we wrote this guide the icedtea-8-plugin is not available in the standard repository.

sudo add-apt-repository ppa:maarten-fonville/ppa
sudo apt-get update
sudo apt-get install icedtea-8-plugin

we need to rerun the following command:

sudo update-java-alternatives -s java-8-openjdk-i386

Some problem can happen depending the sequence and the way you try to achieve this task. I face some issues with missing or wrong symbolic link.

Here is the output of my /usr/lib/jvm directory :

user@machine:~$ cd /usr/lib/jvm
user@machine:/usr/lib/jvm$ ls -al
total 88
drwxr-xr-x   6 root root  4096 Apr 19 15:39 .
drwxr-xr-x 210 root root 53248 Mar 31 07:41 ..
lrwxrwxrwx   1 root root    23 Apr 19 15:39 default-java -> java-1.8.0-openjdk-i386
lrwxrwxrwx   1 root root    19 Mar  5  2013 java-1.6.0-openjdk-i386 -> java-6-openjdk-i386
-rw-r--r--   1 root root  2345 Jan 26 23:05 .java-1.6.0-openjdk-i386.jinfo
lrwxrwxrwx   1 root root    19 Apr  8  2014 java-1.7.0-openjdk-i386 -> java-7-openjdk-i386
-rw-r--r--   1 root root  2396 Mar 24 16:46 .java-1.7.0-openjdk-i386.jinfo
lrwxrwxrwx   1 root root    19 Jan 29 06:25 java-1.8.0-openjdk-i386 -> java-8-openjdk-i386
-rw-r--r--   1 root root  2501 Jan 29 06:25 .java-1.8.0-openjdk-i386.jinfo
drwxr-xr-x   3 root root  4096 Mar 12  2013 java-6-openjdk-common
drwxr-xr-x   7 root root  4096 Feb 13 09:18 java-6-openjdk-i386
drwxr-xr-x   7 root root  4096 Mar 25 07:59 java-7-openjdk-i386
drwxr-xr-x   7 root root  4096 Apr 19 13:04 java-8-openjdk-i386
lrwxrwxrwx   1 root root    30 Apr 19 15:28 .java-8-openjdk-i386.jinfo -> .java-1.8.0-openjdk-i386.jinfo

The default-java should be linked with your desired JVM.

The command update-java-alternatives complained also with a missing .java-8-openjdk-i386.jinfo file. I created an appropriate link towards the existing .java-1.8.0-openjdk-i386.jinfo file.

 

Enjoy

  • No labels