#java #jvm #jigsaw

bin+lib jimage-rs

A fast and efficient Rust library for working with jimage files used by the Java Platform Module System

3 releases

0.0.4 Oct 9, 2025
0.0.3 Sep 3, 2025
0.0.2 Jun 28, 2025
0.0.1 Jun 21, 2025

#2207 in Parser implementations

Download history 5/week @ 2025-07-13 6/week @ 2025-07-20 1/week @ 2025-07-27 8/week @ 2025-08-17 9/week @ 2025-08-24 134/week @ 2025-08-31 23/week @ 2025-09-07 12/week @ 2025-09-14 16/week @ 2025-09-21 29/week @ 2025-09-28 192/week @ 2025-10-05 42/week @ 2025-10-12 25/week @ 2025-10-19 16/week @ 2025-10-26

276 downloads per month
Used in rusty-jvm

MIT license

34KB
674 lines

jimage-rs

A fast and efficient Rust library for working with jimage files used by the Java Platform Module System.

Crate Docs License

Introduction

jimage-rs is a Rust library and command-line utility for reading and extracting resources from Java image files (jimage).

jimage is a file format used by the Java Virtual Machine (JVM) to store class files and other resources in a compressed format. It is typically found in the lib/modules directory of a Java installation. The format was developed as part of Project Jigsaw (JEP-220) and is used in Java Platform Module System (JPMS).

This crate:

  • is implemented from scratch
  • based on publicly available information (since there is no official jimage file format specification)
  • supports the latest internal version 1.0 of the jimage file format

Library

Sample code of extracting resources from a jimage file:

use std::env;
use std::path::PathBuf;
use jimage_rs::JImage;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let path = PathBuf::from(env::var("JAVA_HOME")?)
        .join("lib")
        .join("modules");
    let jimage = JImage::open(path)?;

    let resource_count = jimage.resource_names_iter().count();
    println!("Total resources in jimage: {}", resource_count);

    match jimage.find_resource("/java.base/java/lang/String.class")? {
        Some(resource) => println!("Resource found, its size is {} bytes", resource.len()),
        None => println!("Resource not found"),
    }

    Ok(())
}

CLI

jimage-rs command-line utility can be used to:

  • extract resources from a jimage file jimage-rs extract -r /java.base/java/lang/String.class $JAVA_HOME/lib/modules
  • list all resources in a jimage file jimage-rs list $JAVA_HOME/lib/modules

License

This project is licensed under the MIT license.

Dependencies

~1.7–2.5MB
~44K SLoC