Invoking Native Code with Java ME
From what I read, Java Native Interface is not supported by the Java ME platform. What are some other possible way for Java ME applications to reuse existing native libraries? ...
From what I read, Java Native Interface is not supported by the Java ME platform. What are some other possible way for Java ME applications to reuse existing native libraries? ...
I need to write a JNI wrapper for windows file system calls. I want to be able to get the size and created date of files on a windows system using the appropriate native library. Can anyone point me in the right direction? thanks ...
I need to call some methods in Wininet.dll from a Java program. I can find plenty of tutorials on how to call a new DLL that I create from Java, but I can't seem to find any tutorials on how to call an already existing DLL from Java. I know this involves JNI, but how, exactly, do I do this? Do I need to call javah on Wininet.h? Where...
I have the following code in a c++ "listener class" (more or less), which calls some function of a Java object. I suspect there's a memory leak: JNIEnv *env = NULL; vm_->AttachCurrentThread(&env, NULL); const jclass cls = env->FindClass(...); const jmethodID meth = env->GetMethodID(...); const jobject obj = env->NewObject(cls, meth, ......
The examples for JNI i've seen map Java native methods to implementation by C++ global functions. Is there a way to set the native methods implementation to be the member functions of a C++ object instead? ...
Hi. While I do my best to clean JNI objects to free native memory in the end of the usage, there are still some that hang around for a long time, wasting system native memory. Is there any way to force the GC to give priority in collection of these JNI proxies? I mean is there a way to cause GC to concentrate on a particular kind of o...
It seems that JNI methods need to be written with the Java class signature built in to them. I want to call a JNI method that I didn't write. Can I call a native method on a library that was not written with my class in mind? ...
What is the common way (or best practice) to optionally use JNI? E.g. I have a Java class and this class is 100% pure Java, so it can run on all platforms. However, on some platforms I'd like to speed up some heavy calculations using JNI - which works fine. Unfortunately I cannot support any existing Java platform in the world. So I gue...
Consider the following C code segments. Segment 1: char * getSomeString(JNIEnv *env, jstring jstr) { char * retString; retString = (*env)->GetStringUTFChars(env, jstr, NULL); return retString; } void useSomeString(JNIEnv *env, jobject jobj, char *mName) { jclass cl = (*env)->GetObjectClass(env, jobj); jmethodId mId = (*...
I mavenize my java-project and don't understand, how add in it native libraries. In my not-maven project i did it via CLASSPATH. I use NetBeans and maven in it. ...
Hi. I'm getting a runt-time "Unsatisfied link error" for libraries installed in Linux system library, which are definitely visible. This project works normally when I let Eclipse to manage it. Does someone know if there any caveats regarding JNI and Maven, and can advice about this case? Thanks in advance. ...
As an example for later use in Android I wrote a simple callback interface. While doing so i ran into the following error or bug or whatever. In C the two commented lines are supposed to be executed resulting in calling the C callback onChange. But instead i get an UnsatisfiedLinkError. Calling the native Method directly in Java works ju...
Dear colleagues, I need raise an exception from C++ code. Raised exception must contain text and code of error. So common form: ThrowNew(jclass clazz, const char *msg) is not applicable. That is why I want create my own instance of java class: public class MyException extends Exception that contains one more property for code. Bu...
As I understand, OSGi services can be unregistered anytime, including when they are in use. Consider an OSGi service which internally makes a long-running JNI call. And while that JNI call is executing, the service is unregistered by OSGi. Will the JNI call be allowed to finish or terminated mid-way? What if it was just a normal non-jn...
I am trying to use (*env)->RegisterNatives to add methods to a defined class which I then add to a callback list. The callback sender of course expects my class to implement a certain interface which I do not. And is failing on execution. If I add the keyword "implements Listener" to my class in Java the javac expects to have the method...
I'm currently working on Mangler's Android implementation. I have a java class that looks like so: public class VentriloEventData { public short type; public class _pcm { public int length; public short send_type; public int rate; public byte channels; }; _pcm pcm; } The signature for my pcm object: $ javap...
How can we new primitive types in JNI. I have a function that returns a jobject. It is possible to return jint, jchar, etc. There is NewString, why not NewInteger, NewCharacter, NewDouble, etc. There is no autoboxing at JNI layer at the moment. I can go with the NewObject call, but this will be too much overhead to create primitive t...
Using JNI can we pass custom data types from Java to C (or vice versa)? I see a mapping of primitive datatypes to types in C however not too sure if we can send across our own data types (e.g. Send across or return an Employee object or something!). ...
I'm trying to create a simple Java app that uses JNI to call some native functions. I've followed the examples in the JNI Programming Guide and can't seem to get them to work. I have the following Hello World program, written in Java: class HelloWorld { private native void print(); public static void main(String [] args) { ...
Hello, uname -mr: B.11.23 ia64 g++ --version: g++ (GCC) 4.4.0 java -version: Java(TM) SE Runtime Environment (build 1.6.0.06-jinteg_20_jan_2010_05_50-b00) Java HotSpot(TM) Server VM (build 14.3-b01-jre1.6.0.06-rc1, mixed mode) I'm trying to run a Java application that uses JNI. It is crashing inside the JNI code with the following (...