Giter Club home page Giter Club logo

rustmathutils's Introduction

Using Rust with Java

Description

A way to use compiled Rust code as native functions in Java.

How to Set Up

  1. Create a Java file that has public static native methods
  2. Compile that file to a header file using javac -h . ClassName.java
  3. Start up a Rust library project
    1. The main file must be lib.rs
    2. In the Cargo.toml file, there should be a dependency for jni = "0.19.0" and a lib section where crate-type = ["cdylib"]
    3. The functions in the Rust file must match the ones in the header file compiled earlier with the same parameters and parameter types
    4. The Rust code should then run like normal and output a Java result (if a return value is needed)
    5. Perform a cargo build on the project
  4. Make the connection using a static code block in Java and grab the DLL file from the Rust project and use System.load() to load the DLL

Notes

Not sure how this could get used in the future. The linking becomes one of the most time consuming parts of the operation, then, calling the native method also creates a performance hinderance. I'd probably have to discover other places where this integration could be used.

rustmathutils's People

Contributors

ultraviolet-ninja avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.