MattRS
MattRS

Reputation: 428

Unable to generate JNI .c file using javah -stubs

I am trying to generate JNI code from my Java class. I was able to generate the header without a problem using javah Whenever I run javah with the -stubs command I get this error:

Error: JNI does not require stubs, please refer to the JNI documentation.

Does anyone know if there is a way to generate a JNI .c file for a class. I can make the file from my header by hand, but it seems like something a tool should be able to do.

I found an unresolved bug request about this from 2000 so I'm not too hopeful. https://bugs.java.com/bugdatabase/view_bug?bug_id=4368114

Upvotes: 4

Views: 2572

Answers (1)

bmargulies
bmargulies

Reputation: 100133

-stubs is a leftover from a long-obsolete first cut at JNI. It never generated anything useful for any version of Java used in the current century.

Just copy the header file into your .c file and add a function body to each function.

Or perhaps have a look at http://jna.java.net/.

Upvotes: 3

Related Questions