jni

Handle a JNI crash

I have a dll that contains legacy C code, I call this dll via JNI, but sometimes the C code crashes and causes the JVM to terminate. Is it there a way to avoid JVM crash? Can I handle the JNI fault and let the JVM survive? :) ...

dose Anybody know what "JNI WARNING: threadid=5 using env from threadid=3" neans?

Full exception is below 12-24 08:59:24.800: WARN/dalvikvm(743): JNI WARNING: threadid=5 using env from threadid=3 12-24 08:59:24.800: WARN/dalvikvm(743): in Ldalvik/system/NativeStart;.run ()V (GetObjectClass) 12-24 08:59:24.800: INFO/dalvikvm(743): "HeapWorker" daemon prio=5 tid=5 VMWAIT 12-24 08:59:24.800: INFO/dalvikvm(7...

Send JNI C stderr/stdout through log4j

My java app uses JNI to invoke a library written in C. This native library logs errors to stderr but I would like to redirect the error stream through my log4j logger somehow. Is this possible? The C library is external - I don't have the source, so cannot change it. Thanks ...

g++: How to unmangle exported symbols

I'm trying to compile a Java library that uses JNI. When I start the program, I see a crash with an UnsatisfiedLinkError, which says that a particular method could not be found in the DLL. On closer inspection, I found out that g++, which I use for compilation and linking, mangled my method names by adding suffixes such as "@8" or "@16"...

File Operations in Android NDK

I am using the Android NDK to make an application primarily in C for performance reasons, but it appears that file operations such as fopen do not work correctly in Android. Whenever I try to use these functions, the application crashes. How do I create/write to a file with the Android NDK? ...

Why can JNI libraries compiled using OpenMP only be called on Java's "main" thread?

I have written a library in C using a variety of the #pragma omp directives to parallelize execution. I am on Mac OS X 10.6. I have then wrapped these functions in a JNI library and called them from my Java application. It seems that calls to native functions containing OpenMP directives crash with EXC_BAD_ACCCESS if they are called fr...

Java JNI - associating resources allocated in C with java objects?

I want to allocate some memory in C and keep it associated with a java object instance, like this: void configure(JNIEnv *object, jobject obj, ....) { char *buf = new char[1024]; // associated <buf> with <obj> somehow } And then later free the memory when the java object gets garbage collected - I could do this by calling a JNI fu...

Can I store the JNI Java Env variable?

Hi, I'm making a lib so that cpp apps can communicate with the JVM. Suppose that the JVM has already started how can I make a cpp binary communicate with the JVM? I think the best solution is to store the JNI env variable in the shared object (so) so I can include it on the cpp and use later. Is that possible? EDIT ---- I want to get ...

Static Members Issue - JasperReports for .Net over jni4Net

I'm trying to fill a report with empty datasource like this JasperPrint print = JasperFillManager.fillReport(@"D:\ImagesReport.jasper", null); Usually the program crashes without notice, but I used watch window and found that this is what I get at net.sf.jni4net.jni.JNIEnv.CallStaticObjectMethodPtr(Class clazz, MethodId methodIdNa...

Instance Members Issue - JasperReports for .Net over jni4Net

In JAVA you'd say : JRXhtmlExporter exporter = new JRXhtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); But using jni4Net I cant find setParameter instance method (Note: It's inherited from JRAbstractExporter). I dont...

Can C++ Application load the .jar File using JNI ?

Hi There, Thanks for having a look at question. I am trying to invoke a java method which is in class files using JNI interface. In turn the called class file should be executing the another .jar file which resides in the same direcotry ? I had hard time acheiving this and I am unsuccessful in executing the .jar file. I mean I am not abl...

Intermittent JVM Crash When Using JNI and COM

I'm trying to call a DLL compiled from VB6 source code that I do not have access to. The VB6 code simply retrieves data from a DB2 database using ADO and my client code grabs that data and marshals it to my Java code. I'm attempting to achieve this using JNI and COM (without a third-party bridge). It works 75% of the time, but the other ...

Java casting problem

Here is the simplified version of the problem: SomeClass c = (SomeClass) obj.getSomeClassParent() not always but it happens sometimes to trigger exception org.somepackage.SomeClass can't be cast to org.somepackage.SomeClass How is this possible ? I suppose it has something to do with the fact that JAI imageio is native lib,...

My first attempt at JNI

I have a binarization code in open cv which displaying the binarization of an jpg image. Also i have a Java frame which contain binarization button (simply core java program). When i click this binarization button it'll display the binarization image. So how can i make a interface between open cv and Java? I mean through JNI. Can anybod...

How to catch JNI/JAVA Exception

Hello, I have JNI layer in my application. In some cases JAVA throws an Exception. How can I get JAVA exception in JNI layer. I have the code something like as follows. if((*(pConnDA->penv))->ExceptionCheck(pConnDA->penv)) { (*(pConnDA->penv))->ExceptionDescribe(pConnDA->penv); (*(pConnDA->penv))->ExceptionClear(pConnDA->penv...

How to debug an App on Android with GDBSERVER?

I'm trying to debug a native shared library that my App uses through JNI. I can attach to a running app just fine with "gdbserver --attach pid" but i need to actually launch my app when i launch the gdbserver command. There's a million blog hits on this topic but none of them seem to be clear as to how you launch your app. They all say ...

Restrict native code functionality from Java

Hello all, I have a java application which uses JNI in some parts to do some work. It follows the usual loading of DLL and then calling native methods of DLL. Is there any way we can restrict what native methods can do from the java application? For example, can we restrict DLLs not to open any files or not to open any sockets even if i...

Call my own Java code from C#

Having my own Java code I'm using C# to call some unmanaged code that call (via JNI) the java code. I'm using JNI since I need to ensure: the ability that the Java code will run over real JVM and not over some .NET VM the ability to attach to the VM for debugging (IKVM does'nt support it) I need free solution The current free solutions...

Blocking Dialog from within JNI code

I'm writing an app that's basically a wrapper around a 250K JNI. The JNI (a game engine) has APIs like handle_penUp(int x, int y). Sometimes it needs to query the user from inside handle_penUp() (via callbacks into Java code), so the dialog I use to implement the query must block. I understand that the main thread of execution can't b...

BWAPI-JBridge: JNI library crashing on load

I'm trying to set up the bwapi-jbridge project to develop my own custom StarCraft: Broodwar AI. I've followed the installation instructions on their wiki to the letter but I just can't seem to get it to run. After launching Broodwar I get the following two errors within 2 seconds of the game starting: Window title: Brood War: Windo...