rusty-jvm 0.5.0

An implementation of a Java Virtual Machine (JVM).
Documentation

rusty-jvm

Platform Crate Docs Build Status License codecov dependency status

Introduction

This project is a Java Virtual Machine (JVM) implemented in Rust, built to run Java programs independently of existing JVMs. Everything related to Java is implemented from scratch. The current version executes Java bytecode in interpreted mode, with the introduction of a Just-In-Time (JIT) compiler identified as a future milestone. The next major objectives include the integration of garbage collection and support for multithreading.

Implemented Key Features

See integration tests for broader examples of supported Java features.

Java Standard Library Classes

This project relies on standard library classes from the JDK 25 (LTS). To run the Java code, you must have JDK 25 (LTS) installed on your machine and ensure the JAVA_HOME environment variable is properly set.

Getting Started

Prerequisites

Ensure the following are set up:

  • A machine running Windows, macOS, or Linux
  • JDK 25 (LTS) installed and configured
  • Rust installed and configured

Example Program: Count Fruits

Create a file named FruitCount.java with the following content:

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class FruitCount {
    public static void main(String[] args) {
        List<String> fruits = List.of("apple", "banana", "apple", "orange", "banana", "apple");

        Map<String, Long> counts = fruits.stream()
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

        System.out.println(counts);
    }
}

Steps to Run

  1. Compile the program using the Java compiler:

    javac FruitCount.java
    
  2. Run it using rusty-jvm:

    cargo run -- FruitCount
    

License

rusty-jvm is licensed under the MIT License.