Java
Java Install and manage Java JDK versions using SDKMAN! for development and testing tools
Languages Quest #5 Beginner

Java

Install and manage Java JDK versions using SDKMAN! for development and testing tools

javajdksdkmanprogramminglanguages
Download as:

What is Java?

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

Java is a programming language and computing platform first released by Sun Microsystems in 1995. It has evolved from humble beginnings to power a large share of today’s digital world, by providing the reliable platform upon which many services and applications are built.

Some of the tools used for testing mobile devices require Java, which you can download using SDKMAN!.

Prerequisites

Install Java Using SDKMAN! (Preferred)

Install the latest version of Java SE:

sdk install java

This will install the latest version based on Eclipse Temurin.

List all Java versions available:

sdk list java

This shows a table with:

  • Vendor - The JDK provider (Corretto, GraalVM, Java.net, Liberica, Temurin, etc.)
  • Use - Indicates if this version is in use
  • Version - The Java version number
  • Dist - Distribution identifier
  • Status - Installation status
  • Identifier - The identifier to use when installing

Install a specific version:

Use the Identifier column from the sdk list java output to specify the version you want. Eclipse Temurin is a popular choice for JDK.

sdk install java <identifier>

Close your terminal session and add Java exports to your ~/.zshrc or ~/.bashrc config file.

Switching JDK Versions

Set global version:

sdk default java <identifier>

Use version in current shell only:

sdk use java <identifier>

Check current version:

sdk current java

List installed versions:

sdk list java | grep "\*"

For more details on SDK version management, refer to the SDKMAN! foundation guide.

Troubleshooting

”java: command not found”

  1. Verify SDKMAN! is initialized:

    sdk version
  2. Check Java is installed:

    sdk list java | grep installed
  3. Set a default version:

    sdk default java <identifier>

JAVA_HOME Not Set

Add to your ~/.zshrc:

export JAVA_HOME=$HOME/.sdkman/candidates/java/current

Then verify:

source ~/.zshrc
echo $JAVA_HOME

Wrong Java Version Being Used

Check what’s controlling your Java:

# Which java is being used
which java

# Is there a .java-version or .sdkmanrc file?
ls -la .java-version .sdkmanrc 2>/dev/null

If a local file is overriding your global version, remove it or update it.

Certificate/SSL Issues

Some corporate networks require custom certificates. If you see SSL errors:

# Import certificate to Java keystore
keytool -import -trustcacerts -keystore $JAVA_HOME/lib/security/cacerts \
  -storepass changeit -alias your-cert -file certificate.crt

Uninstalling

Check Installed Java Versions

/usr/libexec/java_home -V

Also check if Java is managed by SDKMAN:

sdk list java 2>/dev/null | grep installed

Remove JDK via SDKMAN

# list installed versions
sdk list java | grep installed

# uninstall a specific version
sdk uninstall java <version>

To remove SDKMAN itself and all its managed SDKs:

rm -rf ~/.sdkman

Remove the SDKMAN initialization from ~/.zshrc or ~/.bashrc:

# remove these lines
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

Remove JDK via Homebrew

brew list | grep -i "openjdk\|java\|temurin"
brew uninstall --cask --zap temurin
# or
brew uninstall openjdk

Remove Manually Installed JDKs (Oracle / OpenJDK)

JDKs installed via .dmg or .pkg installers are in /Library/Java/JavaVirtualMachines/:

# list installed JDKs
ls /Library/Java/JavaVirtualMachines/

# remove a specific JDK
sudo rm -rf /Library/Java/JavaVirtualMachines/<jdk-name>.jdk

sudo is required because /Library/Java/ is a system directory owned by root.

Remove Java Plugins and Preferences

Remove the Java browser plugin and system preferences pane (if installed by Oracle JDK):

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Application\ Support/Oracle/Java

Remove jenv (If Used)

brew uninstall jenv
rm -rf ~/.jenv

Remove jenv initialization from ~/.zshrc or ~/.bashrc:

# remove these lines
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

Clean Up Shell Configuration

Remove any Java-related environment variables from ~/.zshrc or ~/.bashrc:

# remove lines like these
export JAVA_HOME=...
export PATH=$PATH:$JAVA_HOME/bin

Then reload your shell config or restart your terminal:

source ~/.zshrc   # or source ~/.bashrc

Verify Removal

# should return "No Java runtime present"
java -version

# should return empty or "Unable to find any JVMs"
/usr/libexec/java_home -V

which java will still resolve to /usr/bin/java on macOS β€” this is a system stub, not an installed JVM. Use java -version and /usr/libexec/java_home -V to confirm the JVM is removed.

Resources

πŸ”—
What is Java? java.com

Official introduction to Java from Oracle

πŸ”—
SDKMAN! Usage Documentation sdkman.io

Learn how to manage Java versions with SDKMAN!

πŸ”—
Eclipse Temurin adoptium.net

Recommended open-source JDK distribution