Java 10 and first surprise with JNI

Well, you will be surprised with Java 10 and JNI. They have warned – that’s true, but it escalated quickly ;)

> javah -jni -d c -cp target recipeNo001.HelloWorld
javah: No such file or directory

you have to switch to javac and use it’s new feature of generating JNI headers directly from java files instead of class files

> javac -h c -d target java/recipeNo001/

In fact, the whole process is much simpler now as you don’t need intermediate step with javah.

There is one more issue here. New approach not always mean better one. It looks like this change may affect people who don’t have access to source codes: Generate JNI header files for class files in JDK 10. You can get it, sort of, fixed by decompiling class files: How to solve missing javah in Java 10 – ugly way