Skip to content

Commit 15d9a4c

Browse files
install: update to java 21 instructions
1 parent 4e4d974 commit 15d9a4c

1 file changed

Lines changed: 44 additions & 37 deletions

File tree

docs/install/java.md

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
![Java](https://raw.githubusercontent.com/practicalli/graphic-design/live/banners/practicalli-java-adoptium-banner.png)
22

3-
Java is a host platform for Clojure, on which Clojure projects and tools run. [No experience of Java or its platform is required](#what-you-need-to-know-about-java) for successful Clojure projects.
3+
Java is a host platform for Clojure, on which Clojure projects and tools run. Java provides a virtual machine which runs the bytecode generated when Clojure code is compiled.
44

5-
!!! INFO "Practicalli recommends OpenJDK version 17 or 21"
5+
Java virtual machine includes a Just In Time (JIT) compiler that optimises running of bytecode.
66

7+
!!! INFO "Practicalli recommends OpenJDK version 21"
78

8-
# Install Java
9+
10+
## Install Java
911

1012
Check to see if there is an appropriate version of Java already installed.
1113

1214
Open a terminal and run the command
1315

1416
```bash
15-
java -version
17+
java --version
1618
```
1719

18-
If Java is installed, you will see something like this in your terminal:
20+
If Java is installed and on the execution path, the version infomation is returned
1921

20-
![Java version check - dark version](https://raw.githubusercontent.com/practicalli/graphic-design/live/clojure/clojure-cli/clojure-install-java-version-linux-dark.png#only-dark)
21-
![Java version check - light version](https://raw.githubusercontent.com/practicalli/graphic-design/live/clojure/clojure-cli/clojure-install-java-version-linux-light.png#only-light)
22+
![Java version check - dark version](https://github.com/practicalli/graphic-design/blob/live/java/screenshots/java-openjdk-21-version-in-terminal-light.png?raw=true#only-light)
23+
![Java version check - light version](https://github.com/practicalli/graphic-design/blob/live/java/screenshots/java-openjdk-21-version-in-terminal-dark.png?raw=true#only-dark)
2224

23-
If the version is `17` or above, then [jump to the Clojure install page](clojure-cli.md)
2425

2526
=== "Debian Packages"
2627
Install Java development kit (JDK) using the `apt` package manager (login as `su -` or prefix the command with `sudo`)
2728

2829
```bash
29-
apt install openjdk-17-jdk
30+
apt install openjdk-21-jdk
3031
```
3132

3233
??? HINT "Check available versions of OpenJDK"
@@ -36,33 +37,39 @@ If the version is `17` or above, then [jump to the Clojure install page](clojure
3637
apt search --names-only openjdk
3738
```
3839

39-
??? HINT "Optionally include Java sources"
40-
Install the `openjdk-17-source` package to support navigation of Java Object and Method source code, especially useful when using Java Interoperability from within Clojure code.
40+
??? HINT "Optionally include Java docs and sources"
41+
Install the `openjdk-21-doc` locally to provide Javadocs to support Java Interop code.
42+
43+
Install the `openjdk-21-source` package to support navigation of Java Object and Method source code, especially useful when using Java Interoperability from within Clojure code.
44+
4145
```bash
42-
sudo apt install openjdk-17-source
46+
sudo apt install openjdk-21-doc openjdk-21-source
4347
```
4448

4549
[:fontawesome-solid-book-open: Practicalli Clojure CLI Config](/clojure/clojure-cli/practicalli-config/) provides the `:src/java17` alias to include the Java sources in the classpath when running a REPL.
4650

47-
If `openjdk-17-jdk` package is not available, add the [Ubuntu OpenJDK personal package archive](https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa){target=_blank}
51+
If `openjdk-21-jdk` package is not available, add the [Ubuntu OpenJDK personal package archive](https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa){target=_blank}
4852

49-
```bash
50-
sudo add-apt-repository ppa:openjdk-r/ppa
51-
sudo apt-get update
52-
```
53-
If you have more than one version of Java installed, set the version by opening a terminal and using the following command
53+
!!! NOTE ""
54+
```bash
55+
sudo add-apt-repository ppa:openjdk-r/ppa
56+
sudo apt-get update
57+
```
58+
When multiple versions of Java are installed, set the version using the `update-alternatives` command in a terminal
5459

55-
```bash
56-
sudo update-alternatives --config java
57-
```
60+
!!! NOTE ""
61+
```bash
62+
sudo update-alternatives --config java
63+
```
5864
Available java versions will be listed. Enter the list number for the version you wish to use.
5965

6066
=== "Homebrew"
6167
Using [Homebrew](https://brew.sh/){target=_blank}, run the following command in a terminal to install Java 17:
6268

63-
```bash
64-
brew install openjdk@17
65-
```
69+
!!! NOTE ""
70+
```bash
71+
brew install openjdk@21
72+
```
6673

6774
??? HINT "Switching between Java versions"
6875
More than one version of Java can be installed on MacOSX. Set the Java version by opening a terminal and using one of the following commands
@@ -72,9 +79,9 @@ If the version is `17` or above, then [jump to the Clojure install page](clojure
7279
/usr/libexec/java_home -V
7380
```
7481

75-
Switch to Java version 17
82+
Switch to Java version 21
7683
```bash
77-
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
84+
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
7885
```
7986

8087
Alternatively, install [JEnv Java version manager](https://www.jenv.be/)
@@ -106,28 +113,28 @@ If the version is `17` or above, then [jump to the Clojure install page](clojure
106113

107114
Run the file once downloaded and follow the install instructions.
108115

109-
![Adoptium Prebuilt OpenJDK Binaries - web page](https://raw.githubusercontent.com/practicalli/graphic-design/live/java/screenshots/java-adoptium-website-temurin-17.png)
116+
![Adoptium Prebuilt OpenJDK Binaries - web page](https://github.com/practicalli/graphic-design/blob/live/java/screenshots/java-adoptium-website-temurin-21.png?raw=true)
110117

111118

112119
## Multiple versions of Java
113120

114-
[jenv](https://www.jenv.be/) provides a simple way to switch between multiple installed versions of Java. jenv can be used to set the java version globally, for the current shell or for a specific project by adding `.java-version` file containing the Java version number in the root of the project.
121+
[:globe_with_meridians: jenv](https://www.jenv.be/){target=_blank} provides a simple way to switch between multiple installed versions of Java. jenv can be used to set the java version globally, for the current shell or for a specific project by adding `.java-version` file containing the Java version number in the root of the project.
115122

116123

117-
??? INFO "A little Java Knowledge"
124+
## A little Java Knowledge
118125

119-
Very little knowledge of the Java language or the Java Virtual Machine is required.
126+
Very little knowledge of the Java language or the Java Virtual Machine is required.
120127

121-
It is quite simple to call Java methods from Clojure, although there are a wealth of functions and libraries provided by Clojure and its community to minimise the need for Java Interoperability.
128+
It is quite simple to call Java methods from Clojure, although there are a wealth of functions and libraries provided by Clojure and its community to minimise the need for Java Interoperability.
122129

123-
[Reading stack traces](https://8thlight.com/blog/connor-mendenhall/2014/09/12/clojure-stacktraces.html){target=_blank} may benefit from some Java experience, although its usually the first couple of lines in a stack trace that describe the issue.
130+
[Reading stack traces](https://8thlight.com/blog/connor-mendenhall/2014/09/12/clojure-stacktraces.html){target=_blank} may benefit from some Java experience, although its usually the first couple of lines in a stack trace that describe the issue.
124131

125-
Clojure uses its own build tools (Leiningen, Clojure CLI tools) and so Java build tool knowledge is not required.
132+
Clojure uses its own build tools (Leiningen, Clojure CLI tools) and so Java build tool knowledge is not required.
126133

127-
When libraries are added to a project, they are downloaded to the `$HOME/.m2` directory. This is the default Maven cache used by all JVM libraries.
134+
When libraries are added to a project, they are downloaded to the `$HOME/.m2` directory. This is the default Maven cache used by all JVM libraries.
128135

129-
`clojure -Spom` will generate a Maven pom.xml file used for deployment. Understanding of a [minimal Maven POM (pom.xml) file](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#minimal-pom){target=_blank} is useful when managing issues with packaging and deployment.
136+
`clojure -Spom` will generate a Maven pom.xml file used for deployment. Understanding of a [minimal Maven POM (pom.xml) file](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#minimal-pom){target=_blank} is useful when managing issues with packaging and deployment.
130137

131-
[Maven in 5 minutes](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html){target=_blank .md-button}
138+
[Maven in 5 minutes](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html){target=_blank .md-button}
132139

133-
The Java Virtual Machine is highly optimised and does not usually require any options to enhance its performance. The most likely configuration to supply to the JVM are to manage the amount of memory assigned, specifically for resource constrained environments.
140+
The Java Virtual Machine is highly optimised and does not usually require any options to enhance its performance. The most likely configuration to supply to the JVM are to manage the amount of memory assigned, specifically for resource constrained environments.

0 commit comments

Comments
 (0)