Java-Mocha is a Rust-based JDK version management tool that helps you easily install, switch, and manage multiple JDK versions on Windows systems.
java-mocha/
├── src/
│ ├── core/ # Core modules
│ │ ├── datatype.rs # Data type definitions
│ │ ├── foojay.rs # FooJay API interaction
│ │ ├── handler.rs # JSON data processing
│ │ ├── style.rs # Styling and display
│ │ └── utils.rs # Utility functions
│ ├── func/ # Functional modules
│ │ ├── config.rs # Configuration management
│ │ ├── install.rs # JDK installation
│ │ ├── list.rs # JDK list display
│ │ ├── query.rs # JDK query
│ │ ├── switch.rs # JDK switching
│ │ ├── sync.rs # Data synchronization
│ │ └── uninstall.rs# JDK uninstallation
│ ├── lib.rs # Library entry
│ └── main.rs # Program entry
├── Cargo.toml # Project configuration
└── README.md # Project description
Defines the core data types used in the project:
PackageInfo: JDK package information, including download links, checksums, etc.Distribution: JDK distribution enum, such as Oracle, OracleOpenJdk, etc.Architecture: System architecture enumOperatingSystem: Operating system enumArchiveType: Archive type enumSupportTerm: Support term enum
Module for interacting with the FooJay API, providing the following functions:
search_distributions: Search for JDK distributionssearch_versions: Search for JDK versionssearch_packages: Search for JDK packages
JSON data processor, providing data query, filtering, sorting, and other functions.
Styling and display module, responsible for formatting output in the terminal:
show_table: Display data in table formatshow_tree: Display version list in tree structure
Utility function module, including:
- File decompression (zip, tar.gz)
- HTTP client construction
- File download and progress display
- SHA256 checksum calculation
- JSON data read/write
- Symbolic link creation
Configuration management module, responsible for:
- JVM root directory management
- Configuration file loading and saving
- Path initialization
Data synchronization module, synchronizing JDK distribution, version, and package information from the FooJay API to local JSON files.
JDK query module, supporting:
- Query by distribution
- Query by version
- Query by support term
JDK installation module, implementing the complete installation process:
- Query package URL
- Get package information and checksum
- Download and verify file
- Decompress to target directory
JDK switching module, implementing JDK version switching through symbolic links.
JDK list display module, supporting the display of:
- Locally installed JDKs
- Supported distributions
- Available version information
JDK uninstallation module, responsible for deleting installed JDK directories.
- Rust 1.60+
- Windows system
cargo build --releasecargo run --releasecargo testJava-Mocha can be used as a command-line tool and also provides APIs for integration by other programs.
Main APIs include:
sync_data: Synchronize JDK dataquery_info: Query JDK informationfull_install_process: Install JDKswitch_jdk: Switch JDK versionuninstall_jdk: Uninstall JDK
Issues and Pull Requests are welcome to improve Java-Mocha.
- Follow official Rust coding conventions
- Use
cargo fmtto format code - Use
cargo clippyto check code quality
- Fork the project
- Create a feature branch
- Commit changes
- Initiate a Pull Request