It can be done with JNI. As it happens I have a project on GitHub where I have been working on a C++ wrapper generator for Java.
https://github.com/wshackle/java4cpp
Even if you don't want to use it, some of the code or examples might be useful to take a look at.
To compile a JNI program on linux ( which I think should also work for Rasberry PI although I have never used a Rasberry PI) , I would use a command of the form:
export JAVA_HOME=/usr/local/jdk1.8.0_60
g++ -I ${JAVA_HOME}/include -I ${JAVA_HOME}/include/linux -L ${JAVA_HOME}/jre/lib/i386/server/ -Wl,--rpath ${JAVA_HOME}/jre/lib/i386/server/ cpplussource.cpp -ljvm -o newprogram
I am not sure which processor the Rasberry-PI uses. i386 might be replaced with something else. Your JDK might come with a client directory rather than a server directory.
There is more on the C++ compiler options at :
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#compiling_loading_and_linking_native_methods
and more on invoking the virtual machine at:
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#overview