简体   繁体   中英

Generate java code from existing c header and source

I have existing header (.h) and source (.c) files with some C code that i want to use in java. I have worked with JNI, but in all those cases i had a dll and had to write a java class that would generate a header file. But in this case i have a header file allready and raw souce code. Is there any easy way to generate java code that calls this C code ?

I have not worked with C so far so i have no clue on how to compile C code. There is a make file delivered with the C code, but i am unsure on what it will create. I ran the make file in linux enviroment and it created a file without any extension which ran a short test, but u don't know if it compiled the whole code.

Have a look at JNA . It's much more simple to use than JNI.

But to be able to use JNA/JNI, you need a shared library. You seem to have something that creates an executable. To run an external process, use common-exec or, if you know exactly what you're doing, you can try the ProcessBuilder API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM