First Steps
Learn the essential Kopi commands and concepts to manage your JDK versions effectively.
Understanding Kopi
Kopi manages JDK versions at three levels:
- Global - Default JDK version for your system
- Project - JDK version for a specific project directory
- Shell - Temporary JDK version for current shell session
Essential Commands
Viewing JDK Information
# Show current JDK version
kopi current
# List installed JDKs
kopi list
# Search available JDKs
kopi search
# Get detailed JDK information
kopi which java
Installing JDKs
# Install with automatic selection
kopi install 21 # Installs recommended distribution
# Install specific distribution
kopi install corretto@21
kopi install temurin@17
kopi install graalvm@21
# Install exact version
kopi install temurin@21.0.2+13
Managing Versions
# Set global default
kopi global 21
# Set project version
kopi local 17
# Temporary shell override
kopi shell 11
Removing JDKs
# Uninstall a JDK
kopi uninstall temurin@17
# List installed JDKs to see what can be removed
kopi list
# Uninstall specific versions
kopi uninstall corretto@11
Working with Projects
Creating Version Files
Kopi supports two version file formats:
# Native Kopi format (.kopi-version)
echo "temurin@21" > .kopi-version
# Compatibility format (.java-version)
echo "17" > .java-version
Version File Priority
When multiple version files exist, Kopi uses this priority:
.kopi-version
(highest priority).java-version
- Global default
Shell Integration
Automatic Switching
Once shell integration is configured, Kopi automatically switches JDK versions when you:
- Enter a directory with a version file
- Run Java commands
- Start a new shell session
Manual Override
# Temporary override for current shell
kopi shell 11
# Run single command with different JDK
KOPI_JAVA_VERSION=17 java --version
Tips and Best Practices
- Use version files - Always use
kopi local
to set versions in projects for consistency - Specify distributions - Be explicit about which JDK distribution you need
- Regular updates - Keep your metadata cache updated with
kopi cache refresh
- Clean up - Regularly check installed JDKs with
kopi list
and remove unused ones withkopi uninstall
Next Steps
- Managing JDK Versions - Advanced version management
- Working with Projects - Project configuration
- Shell Integration - Configure your shell