Child pages
  • Install or Uninstall Java

Versions Compared

Key

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

Table of Contents

Introduction

After checking your Java Environment, downloaded and installed either an Oracle JDK or an Open JDK, now it's time to pack everything together.

At this point, you have a JVM installed below your /usr/lib/jvm directory and you've a jinfo file tuned to your needs with a unique priority number.

Anchor
Install
Install
Install

Now it's time to link /etc/alternatives with our new installed JVM. 

Anchor
InstallCommandLine
InstallCommandLine
Command Line

Usually one has to install each java commands, tools or libraries one by one with the following interactive command:

...

Code Block
languagebash
themeEmacs
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/default-java/jre/bin/java" 1073;

Check if your added JVM java command has been processed by running:

Code Block
languagebash
themeEmacs
user@machine:~$ update-alternatives --list java
/usr/lib/jvm/default-java/jre/bin/java
/usr/lib/jvm/java-8-openjdk-i386/jre/bin/java
/usr/lib/jvm/java-8-oracle/jre/bin/java
/usr/lib/jvm/ramdisk-java-8-oracle/jre/bin/java

Anchor

...

InstallScripting
InstallScripting
Scripting

Doing this task one by one is pretty tedious, we provide a shell script ito facilitate the work.

...

This shell script mirror the content of the jinfo file described in the Java Environment Tutorial.

This shell script file contains various known plugins. However at this time we only describe the Firefox Java plugin support. It is why we suggest the other plugin support as comments.

...

Code Block
languagebash
themeEmacs
user@machine:/usr/lib/jvm/tools$ sudo update-java-alternatives -s default-java
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/appletviewer for appletviewer not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/extcheck for extcheck not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/idlj for idlj not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jarsigner for jarsigner not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jar for jar not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javac for javac not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javadoc for javadoc not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javafxpackager for javafxpackager not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javah for javah not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javapackager for javapackager not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/javap for javap not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jcmd for jcmd not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jconsole for jconsole not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jdb for jdb not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jdeps for jdeps not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jhat for jhat not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jinfo for jinfo not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jmap for jmap not registered; not setting
update-alternatives: error: alternative /usr/lib/jvm/ramdisk-java-8-oracle/bin/jmc for jmc not registered; not setting
...

In our configuration .default-java.jinfo refers to .ramdisk-java-8-oracle.jinfo:

Code Block
languagebash
themeEmacs
user@machine:/usr/lib/jvm$ ls -al .default-java.jinfo 
lrwxrwxrwx 1 root root 30 Jul 12 14:29 .default-java.jinfo -> ./.ramdisk-java-8-oracle.jinfo

The .default-java.jinfo is linked to .ramdisk-java-8-oracle.jinfo who use ramdisk-java-8-oracle as its name. This the reason why the previous command failed.

Code Block
languagetext
name=ramdisk-java-8-oracle
priority=1073
section=main

It means that ramdisk-java-8-oracle should be installed through the Update Alternatives mechanism before we can set the alternatives to default-java or you define a jinfo file with a different priority number.

Then check again that everything is correct with your Java Update Alternatives Environment.

Anchor
Uninstall
Uninstall
Uninstall

Now it's time to unlink /etc/alternatives with the JVM we want to uninstall. 

Anchor
UninstallCommandLine
UninstallCommandLine
Command Line

Usually one has to uninstall each java commands, tools or libraries one by one with the following interactive command:

Code Block
languagebash
themeEmacs
sudo update-alternatives --remove "java" "/usr/lib/jvm/default-java/jre/bin/java";

Anchor

...

UninstallScripting
UninstallScripting
Scripting

Doing this task one by one is pretty tedious, we provide a shell script ito facilitate the work.

...

This shell script mirror the content of the jinfo file described in the Java Environment Tutorial.

This shell script file contains various known plugins. However at this time we only describe the Firefox Java plugin support. It is why we suggest the other plugin support as comments.

...

Then check again that everything is correct with your Java Update Alternatives Environment.