{"id":15069812,"url":"https://github.com/maulingmonkey/jerk","last_synced_at":"2025-04-10T17:33:40.962Z","repository":{"id":36673520,"uuid":"229390136","full_name":"MaulingMonkey/jerk","owner":"MaulingMonkey","description":"JERK: Java Embedding Rust Kit","archived":false,"fork":false,"pushed_at":"2023-05-17T17:58:38.000Z","size":130,"stargazers_count":17,"open_issues_count":6,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T13:17:29.052Z","etag":null,"topics":["java","jvm","metabuild","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaulingMonkey.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-21T06:57:01.000Z","updated_at":"2023-11-03T02:36:27.000Z","dependencies_parsed_at":"2024-10-13T04:20:46.745Z","dependency_job_id":"7b84d0bc-cefe-4865-94f2-e530a4655c1a","html_url":"https://github.com/MaulingMonkey/jerk","commit_stats":{"total_commits":64,"total_committers":5,"mean_commits":12.8,"dds":0.0625,"last_synced_commit":"adba192b2d660ea3fd73220f9f6a5be2698db8f1"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaulingMonkey%2Fjerk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaulingMonkey%2Fjerk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaulingMonkey%2Fjerk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaulingMonkey%2Fjerk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaulingMonkey","download_url":"https://codeload.github.com/MaulingMonkey/jerk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262020,"owners_count":21074229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jvm","metabuild","rust"],"created_at":"2024-09-25T01:44:49.746Z","updated_at":"2025-04-10T17:33:40.932Z","avatar_url":"https://github.com/MaulingMonkey.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **jerk**: **J**ava **E**mbedding **R**ust **K**it\n\n[![Crates.io](https://img.shields.io/crates/v/jerk.svg)](https://crates.io/crates/jerk)\n[![Docs](https://docs.rs/jerk/badge.svg)](https://docs.rs/jerk/)\n[![GitHub](https://img.shields.io/github/stars/MaulingMonkey/jerk.svg?label=GitHub\u0026style=social)](https://github.com/MaulingMonkey/jerk)\n[![unsafe: yes](https://img.shields.io/github/search/MaulingMonkey/jerk/unsafe%2bextension%3Ars?color=yellow\u0026label=unsafe)](https://github.com/MaulingMonkey/jerk/search?q=unsafe+extension%3Ars)\n[![rust: 1.54.0+](https://img.shields.io/badge/rust-1.54.0%2B-green.svg)](https://gist.github.com/MaulingMonkey/c81a9f18811079f19326dac4daa5a359#minimum-supported-rust-versions-msrv)\n[![License](https://img.shields.io/crates/l/jerk.svg)](https://github.com/MaulingMonkey/jerk)\n\nLibraries to compile/embed/test Java alongside a Rust library/application.\nSimilar to [cc], but for Java.\nThis is **not** an official project of Google, Oracle, Sun Microsystems, or anyone else.\n\n\n| Branch | Badges | Notes |\n| ------ | ------ | ----- |\n| [publish](https://github.com/MaulingMonkey/jerk/tree/publish) | [![Open issues](https://img.shields.io/github/issues-raw/MaulingMonkey/jerk.svg)](https://github.com/MaulingMonkey/jerk/issues) | Stable/published version\n| [master](https://github.com/MaulingMonkey/jerk/tree/master)   | [![Build Status](https://github.com/MaulingMonkey/jerk/workflows/Rust/badge.svg)](https://github.com/MaulingMonkey/jerk/actions?query=workflow%3Arust) | \"Completed\" stuff that hasn't been published.\n| wip/*                                                         | | \"Work In Progress\" - incomplete, use at your own risk.\n| dead/*                                                        | | Abandoned threads of work\n\n## Goals\n\n* Minimal dependencies\n* Compile small amounts of Java before/alongside your Rust code via `javac`, `jar`, etc.\n* **TODO?:** Compile small amounts of Kotlin before/alongside your Rust code via [`kotlinc`] etc.\n* **TODO?:** Compile small amounts of whatever JVM language before/alongside your Rust code via Ant, Groovy, etc.\n* **TODO?:** Auto-locate tools based on env vars, common paths, etc.\n* **TODO?:** Auto-install missing tools for you.\n\n## Non-Goals\n\n* Directly compete with Ant, Groovy, etc. as a fully fledged Java build tool.\n\n## Quick Start\n\n[Install the JDK](https://github.com/MaulingMonkey/jerk/wiki/Installing-the-JDK) if you haven't already.\n\nAdd this to your [Cargo.toml](https://github.com/MaulingMonkey/jerk/blob/master/example-hello-world-jar/Cargo.toml#L10-L20):\n\n```toml\n[lib]\ncrate-type = [\"rlib\", \"dylib\"]\n\n[dependencies]\njni-sys     = \"0.3\"\n\n[build-dependencies]\njerk        = \"0.2\"\n\n[dev-dependencies]\njerk        = \"0.2\"\n```\n\nAnd this to your [build.rs](https://github.com/MaulingMonkey/jerk/blob/master/example-hello-world-jar/build.rs):\n\n```rust\nfn main() {\n    jerk::metabuild();\n}\n```\n\nYou can then write Java ([src/Adder.java](https://github.com/MaulingMonkey/jerk/blob/master/example-hello-world-jar/src/Adder.java)) code:\n\n```java\npackage com.maulingmonkey.jerk.example_hello_world_jar;\npublic class Adder {\n    public native int add(int a, int b);\n    public static void test() {\n        System.loadLibrary(\"example_hello_world_jar\");\n        assert adder.add(1, 2) == 3;\n    }\n}\n```\n\n...alongside your Rust ([src/Adder.rs](https://github.com/MaulingMonkey/jerk/blob/master/example-hello-world-jar/src/Adder.rs)) code:\n\n```rust\nuse jni_sys::{JNIEnv, jobject, jint};\n#[no_mangle] pub extern \"stdcall\" fn Java_com_maulingmonkey_jerk_example_1hello_1world_1jar_Adder_add__II(_env: *mut JNIEnv, _this: jobject, a: jint, b: jint) -\u003e jint {\n    a + b\n}\n```\n\n...and write Java integration tests ([tests/test.rs](https://github.com/MaulingMonkey/jerk/blob/master/example-hello-world-jar/tests/test.rs)):\n\n```rust\n#[test] fn test() {\n    jerk::run_test!(\"com.maulingmonkey.jerk.example_hello_world_jar\", \"Adder\", \"test\");\n}\n```\n\n...and then build and run the test!\n\n```text\nC:\\local\\jerk\u003ecargo t\n    Finished dev [unoptimized + debuginfo] target(s) in 0.06s\n     Running target\\debug\\deps\\example_hello_world_jar-2997df28c387b743.exe\n\nrunning 1 tests\ntest adder::test ... ok\n\ntest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out\n```\n\n## Java \u003c-\u003e Rust Interop Pontificating\n\nRust code may sanely depend on Java code to build, but not vicea versa:\n* Java's ABI has great metadata (classes, methods, doc info, etc.), Rust doesn't even have a stable ABI.\n* Local Java \u003c- Rust \u003c- Java dependency cycles at compile time would be terrible to manage.\n\nYou can still have:\n* Java call into Rust, it should just be through `native` methods declared in Java.\n* Rust-driven packaging bundle Java JARs (e.g. when creating Android APKs) as a final step.\n* Rust define runtime classes implementing interfaces, they just wouldn't be visible to Java at compile time.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n* MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n\u003c!-- https://doc.rust-lang.org/1.4.0/complement-project-faq.html#why-dual-mit/asl2-license? --\u003e\n\u003c!-- https://rust-lang-nursery.github.io/api-guidelines/necessities.html#crate-and-its-dependencies-have-a-permissive-license-c-permissive --\u003e\n\u003c!-- https://choosealicense.com/licenses/apache-2.0/ --\u003e\n\u003c!-- https://choosealicense.com/licenses/mit/ --\u003e\n\n[cc]:                       https://crates.io/crates/cc\n[`kotlinc`]:                https://kotlinlang.org/docs/tutorials/command-line.html\n[build.rs]:                 https://doc.rust-lang.org/cargo/reference/build-scripts.html\n[metabuild]:                https://github.com/rust-lang/rfcs/blob/master/text/2196-metabuild.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaulingmonkey%2Fjerk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaulingmonkey%2Fjerk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaulingmonkey%2Fjerk/lists"}