- Ultra-fast JDK scanning: Reduced scanning time from 3 seconds to 300ms (90% improvement)
- Concurrent processing: Implemented Dispatcher-Worker model with goroutines
- Smart filtering: Aggressive pre-filtering to skip unnecessary directories
- Progress tracking: Real-time scanning progress and detailed statistics
- Linux support completed: Full Linux compatibility with multi-shell support
- Windows optimization: Enhanced path validation and compatibility fixes
- macOS preparation: Infrastructure ready for macOS support (coming soon)
- Java path validation: Improved Windows JDK detection reliability
- Environment management: Optimized cross-platform environment variable handling
- Configuration cleanup: Removed unused options and improved code maintainability
Jenv
is a command-line tool for managing multiple Java versions on your system. It allows you to easily switch between
different Java versions, add new Java installations, and manage your Java environment.
- Symlink-Based Architecture
- Fast version switching through symbolic links
- One-time system PATH configuration
- Changes persist across system reboots
- Instant effect in all console windows
-
Windows Support
- Registry-based environment variable management (Windows standard)
- Automatic administrator privilege handling
- Minimized UAC prompts with least privilege principle
- Superior performance on Windows 10/11 systems
-
Linux/Unix Support
- Shell configuration file-based environment management
- User-level and system-level configuration options
- Multi-shell environment support (bash, zsh, fish)
- Intelligent permission handling
- User-Friendly Interface
- Intuitive command structure
- Light/Dark theme support
- Colorful output for improved readability
- Detailed help documentation
- Smart JDK Management
- System-wide JDK scanning
- Ultra-fast scanning performance (3s β 300ms) using concurrent Dispatcher-Worker model
- Alias-based JDK management
- Current JDK status tracking
- Easy JDK addition and removal
- Detailed scanning statistics and progress display
- Cross-Platform Support
- Windows support (β Complete)
- Linux support (β Complete)
- macOS support (π§ In Progress)
.
βββ src/ # Source code directory
β βββ cmd/ # Command implementations
β β βββ add.go # Add JDK command
β β βββ list.go # List JDKs command
β β βββ remove.go # Remove JDK command
β β βββ use.go # Switch JDK command
β β βββ root.go # Root command and flags
β βββ internal/ # Internal packages
β β βββ config/ # Configuration management
β β βββ constants/ # Constants definitions
β β βββ env/ # Environment handling
β β βββ java/ # Java SDK management
β β βββ logging/ # Logging utilities
β β βββ style/ # UI styling
β β βββ sys/ # System utilities
β βββ jenv.go # Main entry point
βββ doc/ # Documentation
βββ .github/ # GitHub configurations
βββ workflows/ # CI/CD workflows
Download the latest release from the Releases page.
- Go 1.21 or higher
- Git
- Windows: Administrator privileges required for system symbolic links
- Linux: Root privileges recommended for system-wide installation (optional)
- Clone the repository:
git clone https://github.com/WhyWhatHow/jenv.git
cd jenv
- Build the project:
cd src
# For Windows (PowerShell)
go build -ldflags "-X github.com/whywhathow/jenv/cmd.Version=1.0.0" -o jenv.exe
# For Linux/macOS
go build -ldflags "-X github.com/whywhathow/jenv/cmd.Version=1.0.0" -o jenv
# For development build (with debug information)
go build -o jenv
# Verify jenv installation
jenv --version
# Initialize jenv (required for first-time use)
jenv init
# Add jenv to your system PATH
jenv add-to-path
Note for Linux users: After initialization, you may need to restart your shell or run:
# For bash users
source ~/.bashrc
# For zsh users
source ~/.zshrc
# For fish users
source ~/.config/fish/config.fish
# Add a new JDK with an alias name
#jenv add <alias> <jdk_path>
jenv add jdk8 "C:\Program Files\Java\jdk1.8.0_291"
#jenv remove <alias>
jenv remove jdk8
jenv list
#jenv use <alias>
jenv use jdk8
#jenv remove <alias>
jenv remove jdk8
jenv current
# Windows
jenv scan c:\
# Linux
jenv scan /usr/lib/jvm
jenv scan /opt
# macOS
jenv scan /Library/Java/JavaVirtualMachines
# Performance: Ultra-fast scanning with concurrent processing
# π Optimized from 3 seconds to 300ms using Dispatcher-Worker model
jenv add-to-path
#jenv theme <theme_name>
jenv theme dark
#jenv help [command]
jenv --version
Windows: Due to Windows system restrictions, creating system-level symbolic links requires running PowerShell as Administrator.
Linux: Administrator privileges (sudo/root) are only required for:
- System-wide installation (symlinks in
/opt/jenv/
) - Modifying system-level environment files (
/etc/environment
)
Without root privileges, jenv will automatically use user-level configuration in your home directory.
While Linux and macOS users have mature tools like sdkman
and jenv
for Java version management, Windows users have
limited options. The existing Jenv-forWindows solution, while
functional, faces performance issues on Windows 10 systems.
This project was born out of two motivations:
- To create a fast, efficient Java version manager specifically optimized for Windows
- To explore AI-assisted development using tools like
cursor
andTrae
while learning Go programming from scratch
The goal is to provide Windows developers with a robust, performant solution for managing multiple Java environments, similar to what Linux and macOS users already enjoy.
Inspired by nvm-windows, JEnv uses symlinks for Java version management across all platforms, which offers several advantages:
-
Symlink-Based Architecture
- Windows: Creates a single symlink at
C:\java\JAVA_HOME
during installation - Linux: Creates symlink at
/opt/jenv/java_home
(system) or~/.jenv/java_home
(user) - Switching Java versions only requires updating the symlink target
- No need to modify system PATH repeatedly
- Changes persist across system reboots and apply to all console windows/shells
- Windows: Creates a single symlink at
-
High-Performance Implementation
- Ultra-fast JDK scanning: Optimized from 3 seconds to 300ms using concurrent processing
- Dispatcher-Worker Model: Parallel JDK detection with worker goroutines
- Intelligent Pre-filtering: Aggressive directory filtering to skip unnecessary locations
- Detailed Statistics: Real-time progress tracking and comprehensive scan results
- Optimized Path Exclusion: Smart logic to avoid scanning duplicate or invalid paths
-
Implementation Details
- During initialization:
- Windows: Creates
JAVA_HOME
directory atC:\java\JAVA_HOME
- Linux: Creates symlink directory based on privileges (system or user level)
- Adds
JAVA_HOME/bin
to system PATH (one-time setup) - Creates initial symlink to default JDK
- Windows: Creates
- When switching versions:
- Simply updates symlink target to desired JDK
- No PATH modifications needed
- Changes take effect immediately in all console windows/shells
- During initialization:
-
Permission Handling
- Windows: Administrator privileges required for system symbolic links
- Linux: Root privileges optional - falls back to user-level configuration
- UAC/sudo prompts handled automatically with minimal privilege scope
- Follows the principle of least privilege
- Permission requests only occur during initialization and version switching
-
Multi-Shell Support (Linux)
- Automatically detects and configures bash, zsh, fish shells
- Updates appropriate configuration files (.bashrc, .zshrc, config.fish)
- Ensures environment variables persist across shell sessions
This approach is more efficient than constantly modifying system PATH variables, providing a cleaner and more reliable solution for Java version management across all supported platforms.
- cobra - A powerful CLI framework for Go
- jreleaser - A release automation tool
- nvm-windows - Inspired our symlink-based approach
- Jenv-for-Windows - A predecessor project for Java version management on Windows
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.