Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


Java

Java is a programming language created by Sun Microsystems. This company was bought out by Oracle Corporation, which continues to keep it up to date.

Reference(s)

Table of contents


Avoid dotfile madness

Prior to installation, make sure you stay in control of your home directory.

Prerequisite(s)

See how to handle Java related dotfiles.


Install

Install a JDK (e.g. v11):

# emerge -a dev-java/openjdk-bin-11
# pacman -S jdk11-openjdk
# apt install openjdk-11-jdk
# yum install java-11-openjdk
# dnf install java-11-openjdk

Config

Managing multiple JDK

$ eselect java-vm list
# eselect java-vm set system 1 # for the whole system
$ eselect java-vm set user 1 # for the current user
Check the result:
$ java -version

$ archlinux-java status
# archlinux-java set java-11-openjdk
Check the result:
$ java -version

List the different alternatives you have:

$ update-alternatives --list java
    > /usr/lib/jvm/java-11-openjdk-amd64/bin/java
    > /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Select an alternative:
$ sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Check the result:
$ java -version


Use

Compile:

# javac main.java

Run:

$ java main.class

TODO


If this cheat sheet has been useful to you, then please consider leaving a star here.