Skip to main content

get_java_architecture

Function get_java_architecture 

Source
pub fn get_java_architecture(java_path: &str) -> Result<String>
Expand description

Determines the architecture (32-bit or 64-bit) of a Java installation.

This function runs various Java commands to determine the architecture. It tries multiple approaches:

  1. Attempts to run Java with -d64 flag
  2. Attempts to run Java with -d32 flag
  3. Parses system properties from -XshowSettings:properties

§Arguments

  • java_path - Path to the Java executable

§Returns

  • Ok(String) containing “64-bit”, “32-bit”, or “Unknown”
  • Err(JavaLocatorError) if the command fails or output cannot be parsed

§Examples

use java_manager;

fn main() -> java_manager::Result<()> {
    let java_path = "/usr/bin/java";
    let arch = java_manager::get_java_architecture(java_path)?;
    println!("Java architecture: {}", arch);
    Ok(())
}