You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
4
4
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.
6
6
7
+
!!! INFO "Practicalli recommends OpenJDK version 21"
7
8
8
-
# Install Java
9
+
10
+
## Install Java
9
11
10
12
Check to see if there is an appropriate version of Java already installed.
11
13
12
14
Open a terminal and run the command
13
15
14
16
```bash
15
-
java -version
17
+
java --version
16
18
```
17
19
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
19
21
20
-

21
-

22
+

23
+

22
24
23
-
If the version is `17` or above, then [jump to the Clojure install page](clojure-cli.md)
24
25
25
26
=== "Debian Packages"
26
27
Install Java development kit (JDK) using the `apt` package manager (login as `su -` or prefix the command with `sudo`)
27
28
28
29
```bash
29
-
apt install openjdk-17-jdk
30
+
apt install openjdk-21-jdk
30
31
```
31
32
32
33
??? 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
36
37
apt search --names-only openjdk
37
38
```
38
39
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
+
41
45
```bash
42
-
sudo apt install openjdk-17-source
46
+
sudo apt install openjdk-21-doc openjdk-21-source
43
47
```
44
48
45
49
[: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.
46
50
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}
48
52
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
54
59
55
-
```bash
56
-
sudo update-alternatives --config java
57
-
```
60
+
!!! NOTE ""
61
+
```bash
62
+
sudo update-alternatives --config java
63
+
```
58
64
Available java versions will be listed. Enter the list number for the version you wish to use.
59
65
60
66
=== "Homebrew"
61
67
Using [Homebrew](https://brew.sh/){target=_blank}, run the following command in a terminal to install Java 17:
62
68
63
-
```bash
64
-
brew install openjdk@17
65
-
```
69
+
!!! NOTE ""
70
+
```bash
71
+
brew install openjdk@21
72
+
```
66
73
67
74
??? HINT "Switching between Java versions"
68
75
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
72
79
/usr/libexec/java_home -V
73
80
```
74
81
75
-
Switch to Java version 17
82
+
Switch to Java version 21
76
83
```bash
77
-
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
84
+
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
78
85
```
79
86
80
87
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
106
113
107
114
Run the file once downloaded and follow the install instructions.
108
115
109
-

116
+

110
117
111
118
112
119
## Multiple versions of Java
113
120
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.
115
122
116
123
117
-
??? INFO "A little Java Knowledge"
124
+
## A little Java Knowledge
118
125
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.
120
127
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.
122
129
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.
124
131
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.
126
133
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.
128
135
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.
130
137
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}
132
139
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