Install for Java¶
The Java binding is the IDL to Java mapping (org.omg.CORBA,
org.omg.PortableServer, org.omg.CosNaming) on the rustorb library,
called through the Foreign Function & Memory API. It needs Java 22 or
later, and two files from the
release:
rustorb-0.7.0.jar, the Java classes (no dependencies)- the shared library
rustorb_ffifrom therustorb-nativearchive for your platform
You also need rustorb-idl to
generate code from IDL.
Download¶
curl -LO https://github.com/rustorb/rustorb/releases/download/v0.7.0/rustorb-0.7.0.jar
curl -LO https://github.com/rustorb/rustorb/releases/download/v0.7.0/rustorb-native-0.7.0-linux-x86_64.tar.gz
tar xzf rustorb-native-0.7.0-linux-x86_64.tar.gz
| Platform | Archive | Shared library in it |
|---|---|---|
| Linux x86_64 | rustorb-native-0.7.0-linux-x86_64.tar.gz |
lib/librustorb_ffi.so |
| Linux aarch64 | rustorb-native-0.7.0-linux-aarch64.tar.gz |
lib/librustorb_ffi.so |
| macOS (Apple silicon) | rustorb-native-0.7.0-macos-aarch64.tar.gz |
lib/librustorb_ffi.dylib |
| Windows x64 | rustorb-native-0.7.0-windows-x86_64.zip |
bin/rustorb_ffi.dll |
The jar is not on Maven Central yet. To use it from Maven or Gradle, install it into your local repository:
mvn install:install-file -Dfile=rustorb-0.7.0.jar \
-DgroupId=org.rustorb -DartifactId=rustorb -Dversion=0.7.0 -Dpackaging=jar
Run with it¶
The JVM must be allowed to call native code, and must find the library. It is looked up, in this order, in:
- the system property
rustorb.ffi.library(the path of the file) - the environment variable
RUSTORB_FFI_LIBRARY(the same) java.library.path- the system's dynamic loader paths (
LD_LIBRARY_PATH, ...)
java --enable-native-access=ALL-UNNAMED \
-Drustorb.ffi.library=$PWD/rustorb-native-0.7.0-linux-x86_64/lib/librustorb_ffi.so \
-cp rustorb-0.7.0.jar:classes Server
ORB.init(args, props) returns the rustorb ORB without setting
org.omg.CORBA.ORBClass.
Generate code from IDL¶
rustorb-idl -bjava -C gen Echo.idl
javac --release 22 -cp rustorb-0.7.0.jar -d classes $(find gen -name '*.java') *.java
The CosNaming stubs are in the jar. Stubs generated by other IDL compilers (JacORB's, for example) work too, as portable stubs.
From source¶
git clone https://github.com/rustorb/rustorb && cd rustorb
cargo build --release -p rustorb-ffi # target/release/librustorb_ffi.so
mvn -f java/pom.xml package # java/target/rustorb-0.7.0.jar
The mapping is described in java-binding.md.