#java #jni #active #host #locate #executable

bin+lib java-locator

Locates a Java installation in the host

5 releases

0.1.5 Jun 19, 2023
0.1.3 Dec 8, 2022
0.1.2 Jan 30, 2020
0.1.1 Jul 1, 2019
0.1.0 Feb 21, 2019

#180 in Development tools

Download history 10163/week @ 2023-11-21 10838/week @ 2023-11-28 12197/week @ 2023-12-05 10385/week @ 2023-12-12 10276/week @ 2023-12-19 9374/week @ 2023-12-26 12467/week @ 2024-01-02 14075/week @ 2024-01-09 15678/week @ 2024-01-16 15652/week @ 2024-01-23 21273/week @ 2024-01-30 10659/week @ 2024-02-06 11016/week @ 2024-02-13 16936/week @ 2024-02-20 17609/week @ 2024-02-27 14405/week @ 2024-03-05

61,129 downloads per month
Used in 29 crates (8 directly)

MIT/Apache

15KB
217 lines

java-locator

crates.io Build

This is a small utility written in Rust.

It locates the active Java installation in the host.

Usage

The utility can be used as a library, or as an executable:

Library

extern crate java_locator;

fn main() -> java_locator::errors::Result<()> {
    let java_home = java_locator::locate_java_home()?;
    let dyn_lib_path = java_locator::locate_jvm_dyn_library()?;
    let libjsig  = java_locator::locate_file("libjsig.so")?;
    
    println!("The java home is {}", java_home);
    println!("The jvm dynamic library path is {}", dyn_lib_path);
    println!("The file libjsig.so is located in {}", libjsig);
    
    Ok(())
}

Executable

Having rust installed, you may install the utility using cargo:

cargo install java-locator --features build-binary

And then, issuing

java-locator

you should have an output like:

/usr/lib/jvm/java-11-openjdk-amd64

You may retrieve the location of the jvm shared library:

java-locator --jvmlib

should give an output like:

/usr/lib/jvm/java-11-openjdk-amd64/lib/server

This may be used in cases when the LD_LIBRARY_PATH (or PATH in windows) should be populated.

You may also retrieve the location of any file inside the Java installation:

java-locator --file libjsig.so

and you can even use wildcards:

java-locator --file libjsig*

The latter two commands should return something like:

/usr/lib/jvm/java-11-openjdk-amd64/lib

License

At your option, under:

Dependencies

~0–0.9MB
~16K SLoC