Skip to content

Commit

Permalink
Add Java installation guide for Linux
Browse files Browse the repository at this point in the history
Author @drustanyjt
Contributed via #93
  • Loading branch information
damithc committed Oct 16, 2024
1 parent 40b0ea6 commit 428b1ef
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Tutorials, how-to guides, getting-started guides, ...
* **[Installation](tutorials/javaInstallation.html)**
* [**:fab-apple: Mac**](tutorials/javaInstallationMac.html)
* [**:fab-windows: Windows**](tutorials/javaInstallationWindows.html)
* [**:fab-linux: Linux**](tutorials/javaInstallationLinux.html)
* [**JAR files**](tutorials/jar.html)
* [**JavaFX**](tutorials/javaFx.html):
* [Part 1: Getting started](tutorials/javaFxPart1.html)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tutorials/javaInstallation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

* [**:fab-apple: Mac**](javaInstallationMac.html) -- If you are on a Mac and you anticipate using JavaFX in your projects, you are using the precise JDK specified in this guide.
* [**:fab-windows: Windows**](javaInstallationWindows.html)
* %%**:fab-linux: Linux**: coming soon ...%%
* [**:fab-linux: Linux**](javaInstallationLinux.html)
64 changes: 64 additions & 0 deletions tutorials/javaInstallationLinux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{% set title="Java 17 Installation Guide for Linux Users" %}
<frontmatter>
title: "{{ title }}"
pageNav: 2
</frontmatter>

# {{ title }}

This guide explains how to install the **==[OpenJDK Java 17](https://openjdk-sources.osci.io/openjdk17/)==** on Linux using the command line. This guide was created using Ubuntu 22.04 but the steps for other Debian based Linux distros should be similar.
This guide assumes you have super user access.


## Installation

* **Update APT repositories** {{ step_numbers }}
* First we need to ensure our apt repositories are updated. Enter the following command in your terminal:
```bash
sudo apt update && sudo apt upgrade
```
Enter your password if prompted.
* **Install JDK**
* Install the Java 17 OpenJDK version by running:
```bash
sudo apt install openjdk-17-jdk
```
Note that the default installation location is usually `/usr/lib/jvm/`.
* **Verify Installation**
* To verify the installation, run:
```bash
java -version
```

<!-- ======================================================================= -->

## Switching between Java versions

If you have multiple versions of Java installed, you can switch between them using `update-alternatives`.

* **To see the currently active Java version** run,
```bash
java -version
```
* **To switch to a different installed version**, run the following command.
```bash
sudo update-alternatives --config java
```
You should see terminal output like this:
<img src="images/javaInstallationLinux/update_alternatives_java.png" style="padding: 10px;">

Follow the instructions to change to your desired version.
For example, to use Java 11 in the image above, type `1` into the terminal.
* **If you don't have the desired version installed**, you can search for it by running the following command:
```bash
sudo apt-cache search openjdk | grep "\-jdk"
```
You should see the available OpenJDK Java versions listed like so:
<img src="images/javaInstallationLinux/list_openjdk_versions.png" style="padding: 10px;">
Decide on one of the available versions and follow the same steps as above to install your desired Java version.
--------------------------------------------------------------------------------
**Authors:**
* Initial Version: Drustan Yeo ([@drustanyjt](https://github.com/drustanyjt))

0 comments on commit 428b1ef

Please sign in to comment.