java-manager
A comprehensive Rust library and command-line tool for discovering, managing, and interacting with Java installations.
The project is currently under development. All bugs related to the project can be reported by submitting issues on GitHub, and we will regularly fix the reported problems
Features
- Cross‑platform – Works on Windows, macOS, and Linux/Unix.
- Java discovery – Find Java installations via
PATH,JAVA_HOME, deep system scans (Everything SDK on Windows, walkdir on Linux), or full system scan (registry + keyword BFS + Microsoft Store +wherecommand). - Detailed metadata – Extract version, vendor, architecture, and the location of the
javaexecutable andJAVA_HOME. - Execution control – Run Java programs (JAR or main class) with configurable memory limits, arguments, and I/O redirection.
- Error handling – Comprehensive error types for path issues, I/O, command execution, and process failures.
Installation
Add this to your Cargo.toml:
[]
= "0.2"
Or use the cargo command:
Usage
Locate Java installations
use ;
// Quick search: look for 'java' in every directory in PATH
let javas = quick_search?;
for java in javas
// Deep search: Everything SDK (Windows) or walkdir (Linux)
let all_javas = deep_search?;
// Full search: multiple scanners without external dependencies
let all_javas = full_search?;
// Check JAVA_HOME environment variable
if let Some = java_home
Execute a Java program
use ;
let java = java_home.expect;
// Run a JAR file
new
.java
.jar
.min_memory // 256 MB
.max_memory // 1 GB
.arg
.redirect
.execute?;
// Or run a main class
new
.java
.main_class
.arg
.arg
.execute?;
Get metadata from a specific Java path
use JavaInfo;
let info = new?;
println!;
println!;
println!;
println!;
println!;
Platform Notes
Three search functions serve different needs:
quick_search()— WalksPATHon all platforms. Fastest, catches the default Java.deep_search()— Windows: Everything SDK (Everything must be installed + running). Linux: same asfull_search().full_search()— No external dependencies. Windows: registry + keyword BFS + Microsoft Store +wherecommand. Linux: walks common directories +~/.minecraft/runtimewith keyword filtering.- macOS: Currently supports the same methods as Linux (will be enhanced).
License
This project is licensed under the MIT License. See the LICENSE file for details.