Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main
target/classes
.gitignore
pom.xml
readme.md

readme.md

SAPLE PROJECT TO LEARN HOW TO USE JNI

In this project you will find a little sum and multiply calculator implemented in C language and runing it in Java.

COMANDS TO COMPILE .SO LIBRARY

The project contains the .so file in the jniexample folder. If you don't change C code, compile is not mandatory.

To generate .o:

gcc -c -fPIC -I /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/include/ -I /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/include/darwin/ com_urbanojvr_jniexample_JavaCalculator.c -o com_urbanojvr_jniexample_JavaCalculator.o

To generate .so from .o:

com_urbanojvr_jniexample_JavaCalculator.o -shared -o libcalculator.so

EXECUTE

To can succesfully run the example, you must fill two constants with valid information.

- JavaCalculator.ABSOLUTE_LIB_DIR: absolute directory to folder that contains the .SO library compiled
- Main.YOUR_NAME: to personalize the greeting
You can’t perform that action at this time.