Child pages
  • Java Environment
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 »

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

This tutorial assume that you have at least one java installed on your system. It has not been tested on an Ubuntu without any installed java. However generalities should apply.

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

The previous command shows us that we have a running java on our system. On Ubuntu 14.04 the Java commands are under the /usr/bin directory.

user@machine$ which java
/usr/bin/java

The previous command shows us that we are running a java command from /usr/bin.

However in order to manage multiple version of Java the update-alternatives mechanism has been introduced. It allows multiple "providers" to be installed on the same machine, and configures which is the default. 

This mechanism consists of two directories, /etc/alternatives who contains the symlinks and /var/lib/dpkg/alternatives who contains update-alternatives state information.

Let's see where is the java command:

user@machine$ ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22 Mar 12 2013 /usr/bin/java -> /etc/alternatives/java

As you can see the java command from /usr/bin is a symlink and will be resolved against the java command contained in /etc/alternatives.

user@machine$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/ramdisk-java-8-oracle/jre/bin/java'

The previous command shows us where lies the java command and hopefully the directory /usr/lib/jvm/ramdisk-java-8-oracle/jre/bin contains the real java command.

user@machine$ ls -al /usr/lib/jvm/ramdisk-java-8-oracle/jre/bin/java
-rwxr-xr-x 1 root root 5730 May 4 10:54 /usr/lib/jvm/ramdisk-java-8-oracle/jre/bin/java

Now take a look in the file /var/lib/dpkg/alternatives/java:

manual
/usr/bin/java
java.1.gz
/usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-i386/jre/bin/java
1069
/usr/lib/jvm/java-8-openjdk-i386/jre/man/man1/java.1.gz
/usr/lib/jvm/java-8-oracle/jre/bin/java
1070
/usr/lib/jvm/java-8-oracle/man/man1/java.1.gz
/usr/lib/jvm/ramdisk-java-8-oracle/jre/bin/java
1073

That file teaches us that there are several java command installed on this machine.

How do we manage that ?

 

 

 

  • No labels