java, javac, and jar.
When to use this command
Use this command when you:- Want to let the system automatically choose the best Java version
- Have manually selected a version and want to return to automatic mode
- Just installed a new Java version with higher priority and want it to become active
- Need to reset your Java configuration to system defaults
- Want to ensure all Java binaries use the highest priority version
How it works
This command usesupdate-alternatives --auto to switch from manual mode to automatic mode. In auto mode, the system always uses the alternative with the highest priority number.
Automatic vs manual mode
Manual mode
- Set when you use Change Version
- System uses your explicitly selected version
- Persists even if higher priority versions are installed
- Remains until you change it or run Update List
Automatic mode
- Set when you use Update List
- System uses the highest priority version
- Automatically updates when new versions are installed
- Recommended for most users
Step-by-step usage
Automatic update process
The tool switches all three Java binaries to auto mode:This happens automatically with sudo privileges.
Completion
After about 1 second, the screen clears and returns to the main menu. Your Java alternatives are now in auto mode.
What happens behind the scenes
The implementation ininternal/commands/updatelistjava.go:11-35 executes three update-alternatives --auto commands:
- Switches the alternative from manual to auto mode
- Evaluates all registered alternatives
- Selects the one with the highest priority
- Updates the symbolic link in
/usr/bin/to point to the highest priority version
Priority-based selection
The system selects the Java version based on priority numbers assigned during installation:| Priority | Typical Java Version |
|---|---|
| 800 | Java 8 |
| 1100 | Java 11 |
| 1700 | Java 17 |
| 2100 | Java 21 |
Higher numbers = higher priority. If you have Java 11 (priority 1100), Java 17 (priority 1700), and Java 21 (priority 2100) installed, auto mode will select Java 21.
Real terminal example
Before running Update List (manual mode)
Running Update List
After running Update List (auto mode)
Common use cases
After installing a new Java version
After installing a new Java version
Automatically switch to the newly installed version:
Resetting after temporary version change
Resetting after temporary version change
Return to the highest priority version after testing:
System-wide default configuration
System-wide default configuration
Set up a machine with sensible defaults:
Troubleshooting inconsistent versions
Troubleshooting inconsistent versions
If your java, javac, and jar are using different versions:
When NOT to use this command
Behavior with priority ties
If two versions have the same priority (rare but possible):- Delete and reinstall with different priorities
- Or use Change Version to manually select your preferred version
Checking current mode
To see if you’re in auto or manual mode:Comparison with other commands
| Command | Mode After | Version Selection |
|---|---|---|
| New Version Java | Unchanged | No change to active version |
| Change Version | Manual | Your selection |
| Update List | Auto | Highest priority |
| Delete Version | Unchanged | Auto-adjusts if deleted version was active |
Best practice: Use auto mode (Update List) for general development unless you have a specific reason to pin a version. This ensures you’re always using the most recent Java version you’ve installed.
Troubleshooting
Update List doesn’t change my active version- Check priorities:
update-alternatives --display java - The version you expect may not have the highest priority
- Use Change Version instead
update-alternativesdoesn’t modifyJAVA_HOME- Update manually:
export JAVA_HOME=/opt/java/jdk-21 - Add to
~/.bashrcfor persistence
- No Java versions are registered
- Install Java using New Version Java
- Auto mode persists across reboots
- If reverting, check startup scripts that might set Java version
- Look for JAVA_HOME exports in
~/.bashrc,~/.profile, etc.