Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to experiment with using the JNI and JDK 9. I have a class NativeTest.java that looks like this:

public class NativeTest {

    static {
        System.loadLibrary("hello");
    }

    private native void sayHello();

    public static void main(String[] args) {
        new NativeTest().sayHello();
    }
}

I compile the class, then use javah NativeTest to generate the header file.

Upon issuing javah, I get this warning:

Warning: The javah tool is planned to be removed in the next major
JDK release. The tool has been superseded by the '-h' option added
to javac in JDK 8. Users are recommended to migrate to using the
javac '-h' option; see the javac man page for more information.

I know it'll be quite a while before the next major JDK release, but I figured I'd start getting used to this new option now.

So upon trying javac -h NativeTest.java (and other variations like NativeTest, NativeTest.class, etc.) I keep getting this error:

javac: no source files

I haven't been able to find any help online, probably because this feature is relatively new, and I can't find anything about this new -h option in the man page.

Anyone else try this yet? What am I missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
537 views
Welcome To Ask or Share your Answers For Others

1 Answer

The solution I discovered was that I was not specifying the directory where javac should place the header files.

Executing javac -h . NativeTest.java worked.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...