Java wrapper for SDRplay API
Note: this is a work in progress and is not yet released.
- Java 18. Uses Project Panama foreign function and foreign memory access incubator features.
- jextract
- SDRplay API installed in runtime environment
- Linux, MacOS, and Windows.
This library uses the new incubator features from JDK 18 JEP 419 Project Panama and the jextract tool to auto-generate java code to interface with native libararies. The jextract tool generates code from the native header file:
- Install the sdrplay api
- Locate the library headers.
- Linux: /usr/local/include/*.h
- Windows: C:\Program Files\SDRplay\API\inc*.h
- MacOS: /usr/local/include/*.h
- cd into the library source directory: (project)/jsdrplay/sdrplay-api/src/main/java/
- Run: jextract -t io.github.dsheirer.sdrplay.api /usr/local/include/sdrplay_api.h -l libsdrplay_api --source
Note: the jextract auto-generated code includes a class RuntimeHelper that loads the library from the default system path. The sdrplay api is installed to a non-default location and the auto-generated code can't find it. Until I can figure out how to make that work, I've added a workaround where the SDRPlay class explicitly loads the library from the installed location. The auto-generated RuntimeHelper library load call is manually commented out.
- Run configuration
- JVM Options: --enable-native-access=ALL-UNNAMED,sdrplay.api,io.github.dsheirer.sdrplay -Djava.library.path=/usr/local/lib
- Add the sdrplay library location to the java.library.path:
- Linux: /usr/local/lib
- Windows: C:\Program Files\SDRplay\API\inc\
- MacOS: ??