Skip to content

Rust calls a native Java shared library generated with Graalvm

License

Notifications You must be signed in to change notification settings

rimerosolutions/rust-calls-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6ba09e · Jan 8, 2022

History

6 Commits
Jan 7, 2022
Jan 8, 2022
Jan 7, 2022
Jan 6, 2022
Jan 6, 2022
Jan 6, 2022
Jan 8, 2022

Repository files navigation

README

What is this?

Overview

This is a very simple example of how a native Java library can be created and called from Rust programs.

./images/overview.png

Minimal use-cases

  • As Rust is relatively new in comparison to Java, there might be mature libraries that can be reused “almost as is”
  • If you’re more comfortable with Java (just like me), you might code few parts of your Rust application in Java (as needed).
    • I don’t know Rust that well and there are programs that would literally take me few hours in Java (vs. few days in Rust)
    • There are several mature Java libraries with no direct equivalent in Rust, that I’d rather not write myself from scratch.

How do I run this?

TL;DR

podman build -t localhost/rust-calls-java .
podman image prune --filter label=stage=rust-calls-java-builder
podman run localhost/rust-calls-java

Option 1 - From Docker or Podman

You’ll need to have either Docker or Podman installed first. I’ll use podman as this is what I have installed, but it’s literally the same syntax for docker.

Build the container image

At the root of this repository, run the following command.

podman build -t localhost/rust-calls-java .

Run the rust executable from the container image

podman run localhost/rust-calls-java

Option 2 - From your local machine

Follow the instructions available in the projects in this git repository:

  • First, build the java-lib project
  • Then, you should be able to build and run the rust-app project

References

About

Rust calls a native Java shared library generated with Graalvm

Topics

Resources

License

Stars

Watchers

Forks