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, or deep system scans (Everything SDK on Windows, common directories on Linux). - 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: use platform‑specific tools to find more installations
let all_javas = deep_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
- Windows: Deep search uses the Everything SDK. Everything must be installed and running.
- Linux: Deep search walks common directories (
/usr/lib/jvm,/usr/java,/opt,/usr/local) and follows symbolic links. - macOS: Currently supports the same methods as Linux (will be enhanced in future releases).
License
This project is licensed under the MIT License. See the LICENSE file for details.