hello everyone
I hope that someone can help me
I have tried to run c code in java using Runtime but I got the following error:
Debug assertion failed
file:fprintf
line:56
althogh the c code is working correctly using visual c++ 6.0 and does not generate error and I'm able to run it using dll but I'm unable to run it using java

Hlppppppppppppppp please
thanks in advance

December 29th, 2009, 11:37 AM

copeg

Re: calling c code from java

First guess is that the c code you are running is missing some sort of input (say perhaps a command line argument that specifies the file name to write to for the fprintf call?), but without further info there's no way to be sure. Can you provide a bit more info (eg code)? Are you using Runtime.exec? Have you provided all command line arguments necessary?

April 6th, 2013, 10:44 PM

nicz17

Re: calling c code from java

In simple terms, just make sure you load the relevant library which contains the function definition, load the library which follows the JNI specification and wraps the target function from the first library, expose native methods from your Java class and you should be good to go.

I'd recommend against raw JNI since it contains a lot of boilerplate code and you would end up cursing yourself if you start wrapping a big C library. By all means do feel free to dabble in JNI when starting out but use something like JNA when it comes to real work.

April 6th, 2013, 10:53 PM

pbrockway2

Re: calling c code from java

@nicz17: This is an ancient thread and what you copy/pasted off the internet is not more than others could have found for themselves.

Please don't resurrect old threads, especially when you have no opinion of your own to add. It's annoying.