jni

Porting a shared memory JNI app from Linux to Windows for use with NTP

I have a small JNI program that uses shared memory to update NTP on a Linux server. The C portion of the code has three functions: attach the shared memory, set the time stored in the shared memory, and detach the shared memory. I would like to be able to run this program in Windows, while keeping the C code at least somewhat portable....

Error in Android application

I have an Android application, a JNI code which captures images from Camera and sends it to UI. JNI code runs in a separate thread which fills a shared queue which is present in UI class. Randomly I am getting the following error. W/dalvikvm( 360): JNI WARNING: 0x659 is not a valid JNI reference W/dalvikvm( 360): in Ldalv...

Copying DLL out of WAR results in LFs becoming CRLFs

I am using the Java Native Interface to include some statically compiled code in with my Java application. Particularly, I've got a DLL file with the compiled code in the WAR that contains my application. Unfortunately, the class loader can't load the DLL from inside the WAR (from preliminary research... if this is wrong, be sure to tel...

Android - failure on loading library

I have a similar problem to this question, but slightly different. I have compiled a .so library to use with JNI. Because it is large (15 MB), I am putting it on the SDCard instead of in the standard application place. The file is called libSample.so and it's located at /data/library/libSample.so I load it in a static initialization ...

Android run application on OS compilation.

I have an Android Application which uses JNI calls. Now i want this application to boot with the Android OS(i.e. my application should compile with Android OS . I'm using Intel Atom board for Android compilation.). My Questions are as follows: 1) Do i follow the same procedure of creating make file and symbolic link with the Android OS ...

Unsatisfed LinkError in java ?

Hi Experts, I am running jython to connect to Bladelogic managers for which i need to connect to it. When i try to do it. It says following Error: java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: no XJNIService in java.library.path. Can you please help me to resolve this issue. Regards Gnash-85 ...

Java JNI - Is it possible to set an individual primitive array element in Java from C++

Basically, I've been doing the following to retrieve Java Instance Fields (in this case, an int) and setting it to a new value like the following: jclass cls = env->GetObjectClass(obj); jfieldID fid = env->GetFieldID(cls, "myVariable", "I"); env->SetIntField(obj, fid, (jint)2012); However, I'd like to do this for an individual int ele...

Is it possible to load different versions of the same DLL in Java?

I have a JNI library that interacts with a set of third party libraries, and there may be more than one version of the third party library on the system. For each version of the third party library, I have to re-compile the JNI code for comparability reasons. Right now I deal with this by loading a DLL with a specific name, and if the ve...

C approximation functions

I am making some approximation functions for exp, log, and sqrt in C for java. I'm a little rusty on how pointers work -- is this grammar correct? #include <math.h> #include "QDMath.h" JNIEXPORT jdouble JNICALL Java_QDMath_exp (JNIEnv *env, jclass class, jdouble val) { jint tmp = (jint) (1512775 * val + 1072632447); jdouble ...

Build a JNI DLL using MINGW

I am trying to create a DLL that will call Qt (currently I can't use Jambi for the functionality I need). I have a simple Java method: public final native int createChild(int handle); I created C project in Visual Studio Express 2010 and was able to build the DLL. Then I created a project in Qt creator and moved my sources there. I t...

Using D to program to the Java Native Interface

I've been looking at the D programming language and it looks like a lot of fun to try for someone already proficient in C++. Can I use D to program to the Java Native Interface which is a C interface? ...

jni calling function not work in first step

hello I have program that use JNI I use Runtime.getRuntime().exec(file path and name); for open an program and when is opened I try to set perant of this program on button listener. I have 2 Native methods that 1 long fw("titlewindow") for get handle with title of window and an other long setparent(fw(),handle of main progarm[I'm sur...

Whether a new process is forked from a JNI call

I am trying to call a C API from my java program using JNI. Could somebody tell me whether the call to C API would fork a new process internally?...I need this because my concurrent transactions would be very huge so that if new process is forked then there would be so many new processes for every transaction. ...

RtlValidateHeap problem when unloading JVM after JNI_CreateJVM loaded

I have trouble with the jvm.dll when after the returning from the function below I get the error message _HEAP[test_heap.exe]: Invalid Address specified to RtlValidateHeap_ At the moment I dynamically load the JNI_CreateJavaVM method only, everything goes well until I go past the final return statement of the function test_heap below: ...

Access C++ shared library from Java: JNI, JNA, CNI, or SWIG?

Which of the following (or other) method would you recommend for accessing a C++ shared library from Java and why? JNI: I hear this has a number of pitfalls and is quite the undertaking? SWIG: Apparently this makes using JNI easier, but I've heard it has some problems too? JNA: I could write a C interface and then use JNA with it i...

JMagick.dll for 64 bit processor

I am trying to run a program to call C++ libraries in ImageMagick using jmagick interface (JNI) from a java program. But I am getting following exception Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jdk1.6.0_16\bin\jmagick.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform I tr...

Programming JNI with Delphi

Can I use Delphi to program to the Java Native Interface? From reading Essential JNI it seems possible if you make sure you are using the C calling convention. Anyone done this before? I would appreciate tips on tools that will help e.g. a tool to convert the C header file of Javah to Delphi. ...

What is the most efficient way to get java buffer in native code under JNI?

Problem: My code native code (c/c++) is called via JNI. Once it's started it needs to get byte[] buffer from Java object several times per second for further heavy processing. Native code should request buffer when processing of previous buffer is completed. The orginal idea was to pass buffer via AF_INET socket to avoid JNI stuff, b...

looking for memory overruns hunting tool for C code that is called from Java

Hi, I'm looking for memory overruns hunting tools for C code that is called from Java via JNI. Usual tools for C like gdb, valgrind don't work. Thanks ...

JNI or Runtime.exec() ??

I need to call a RPC client which is implemented in C from a Java class. The interaction is one way only(i.e) Java has to invoke specific functions in C, while C need not return anything to the calling Java code. Can someone explain me the pros & cons in using either of the types (JNI/Runtime.exec)?? and which is the best option for m...