rusty-jvm
Introduction
This project is an attempt to implement JVM in Rust. The project is for educational purposes only. It is not intended to be a full-featured JVM implementation, but rather a simple one that can run small Java programs. The main goal of this project is to learn how JVM works and how to implement it in Rust. There is no dependency on any existing JVM implementation, everything that regards java is implemented from scratch. There is no garbage collection (yet, I hope).
The standard library classes are used in the project originated from OpenJDK JDK 23 General-Availability Release are located in the lib directory.
Refer integration tests for examples of supported Java features.
Getting Started
Prerequisites
Ensure you have the following:
- A machine running Windows, macOS, or Linux.
- Rust installed and configured.
- The
RUSTY_JAVA_HOME
environment variable is set to the root of this project to locate Java standard library classes.
Example Program
This program calculates the total attack power of a group of units in a game. It features abstract classes, interfaces, and polymorphism to demonstrate the capabilities of rusty-jvm.
;
;
;
;
Steps to Run
- Compile the program using the Java compiler
javac -d . Demo.java
- Run it using rusty-jvm:
cargo run -- game.Demo
Expected Output
If everything is set up correctly, you should see
We embrace the glory of battle!
Battle is upon us!
Group attack power is 57