Overview
JavaOptionsCli provides a streamlined workflow for managing multiple Java installations. This guide walks through the complete process from downloading Java to switching between versions.Step 1: Download Java
Download the Java version you want to install as a.tar.gz archive.
Recommended sources
Step 2: Prepare your workspace
Place the downloaded.tar.gz file in a dedicated directory:
JavaOptionsCli must be executed from the same directory where the
.tar.gz file is located. This is a current design requirement.Step 3: Run JavaOptionsCli
Launch the interactive CLI from the directory containing your tar.gz file:Step 4: Install a new Java version
Select installation option
From the main menu, choose New Version Java.Provide the tar.gz filename
When prompted, enter the exact name of your tar.gz file:Specify the folder name
The tool will extract the archive and show your/opt/java directory. Enter the extracted folder name:
Set the priority version
Provide a priority number forupdate-alternatives. Higher numbers = higher priority:
What happens behind the scenes
JavaOptionsCli performs these operations:- Extracts the
.tar.gzfile to the current directory - Moves the extracted folder to
/opt/java/ - Registers three binaries with
update-alternatives:/opt/java/jdk-21/bin/java→/usr/bin/java/opt/java/jdk-21/bin/javac→/usr/bin/javac/opt/java/jdk-21/bin/jar→/usr/bin/jar
Step 5: Switch between Java versions
Use the change version feature
From the main menu, select Changes Version. You’ll be prompted three times to configure:- The active
javabinary - The active
javaccompiler - The active
jartool
The tool runs
update-alternatives --config for each binary. Choose the same version for all three to avoid mismatches between runtime and compiler.Verify the active version
After switching, verify your Java version:Step 6: View installed versions
Select View List Versions from the menu to see all Java installations registered withupdate-alternatives.
This displays:
- All registered
javabinaries - All registered
javaccompilers - All registered
jartools
Step 7: Remove a Java version (optional)
To uninstall a Java version:- Select Delete Version from the menu
- Enter the folder name (e.g.,
jdk-21) - Choose whether to delete the physical files from
/opt/java
- Remove the version from
update-alternatives - Optionally delete the installation directory
Best practices
Organize your downloads
Keep all Java tar.gz files in a dedicated directory for easy access:Use consistent naming
When extracting, Java archives typically create folders like:jdk-21.0.2jdk-17.0.1jdk-11.0.18
Set appropriate priorities
Use priority numbers that reflect the version hierarchy. This ensuresupdate-alternatives --auto selects the most recent version by default.
Keep runtime and compiler in sync
Always set the same Java version forjava, javac, and jar to avoid compatibility issues.