Java
Table of Contents generated with DocToc
Documentation
-
Rheinwerk<openbook>: Java ist auch eine Insel
-
Baeldung - Baeldung Learning Materials, Courses and Guides
Tools and Frameworks
-
Baeldung: A Guide to JUnit5
Installing Java on Windows
One Java Version Only
-
Chocolatey: temurin - Eclipse Temurin is a part of the Adoptium Enterprise Java Platform replacing AdopOpenJDK.
Switching Between Multiple Versions of Java using SDKMAN
You can install either in a GitBaSH or into Ubuntu on WSL-2.
For GitBaSH you need MinGW-x64 and the zip (and unzip) tools. I am installing them using Chocolatey:
choco install git mingw zip
For Ubuntu in WSL-2 you need zip and unzip:
sudo apt install unzip zip
Next, install SDKMAN
Finally, install the desired java version(s):
sdk list java
...
sdk install java 17.0.7-tem
If you are using JetBrains IntelliJ IDEA, then you can add your Java SDKs via the File -> Project Structure dialog on the Project or Platform Settings/SDKs views. The base folder for the SDK is in C:\Users\yourname\.sdkman\candidates\java\17.0.7-tem
(as an example for java 17 temurin).
Installing Java on macOS
One Java Version Only
On macOS I am installing java by means of Homebrew:
brew install temurin
This will download and install the latest OpenJDK provided by the Adoptium project.
For code development I am using JetBrains IntelliJ IDEA whom I wish to thank for the free license they grant to me because of my open source contributions.
Please check the list of IntelliJ IDEA Plugins I recommend.
Switching Between Multiple Versions of Java
Works For Both Java And Gradle
-
Install sdkman
-
Install java and gradle
# Install latest sdk install java sdk install gradle # Install an alternative version sdk install java 11-ms sdk install gradle 6.7.1
-
Select a default version for java and gradle
sdk default java 11.0.14-ms sdk default gradle 6.7.1
-
Use a different version of java and gradle in the current shell (restored to
default
in the next shell)sdk use java 11-ms sdk use gradle 6.7.1
Works For Java, Doesn’t Work For Gradle
-
Install jenv
brew install jenv # Remember to add the initialization code to .zshrc or .bashrc # Restart your shell
-
Install some Java versions using Homebrew
brew tap homebrew/cask-versions brew install temurin brew install temurin11
-
Find out the Java version paths
/usr/libexec/java_home -V
-
Register the Java version paths with jenv
jenv add ... # for each Java version you'd like to switch to
-
Verify
jenv versions
-
Switch Java version (e.g. 11)
jenv global 11
-
In a specific directory, select a different Java version (e.g. 17)
jenv local 17
API Services and Web Applications
- Hot Swapping - Live reload classes and web content.
- Serving Web Content with Spring MVC - Guide to creating a simple MVC web application.
- Testing the Web Layer - Guide to testing a simple MVC web application.
- Spring Docs: Testing - Reference manual for testing spring applications.
- HtmlUnit - GUI-Less browser for Java programs.
- HtmlUnit 2.60.0 API Documentation - JavaDoc for all HtmlUnit classes.
Links
- Adoptium - Prebuilt OpenJDK Binaries for Free.
- JetBrains IntelliJ IDEA - Java IDE.
- Stackoverflow: Mac OS X and multiple Java versions