jni

How can I Java webstart multiple, dependent, native libraries?

Example: I have two shared objects (same should apply to .dlls). The first shared object is from a third-party library, we'll call it libA.so. I have wrapped some of this with JNI and created my own library, libB.so. Now libB depends on libA. When webstarting, both libraries are places in some webstart working area. My java code attempt...

Getting Java and TWAIN to play together nicely

I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of Morena and JTwain, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool. Is anyone familiar with a free tool that can get a Java applet to re...

JNI and Java: ant calling make or make calling ant?

I'm just about to make my first trip into the world of JNI (Java Native Interface) to provide file system change notifications from platform specific C/C++ code to Java. That is unless someone suggest some brilliant library for doing this that I've missed. Being new to JNI I've managed to find much documentation on the interface side of...

Calling C# code from Java?

Does anyone have a good solution for integrating some C# code into a java application? The code is small, so I could re-write in java, but I would rather reuse the code if possible. Don't repeat yourself, etc. Also, I know I can expose the C# as a web service or whatever, but it has some security/encryption stuff in there, so I would...

faster Math.exp() via JNI?

Hi, I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java's Math.exp()?? I tried just jni + C, but it's slower than just plain java. ...

How do I convert jstring to wchar_t *

Let's say that on the C++ side my function takes a variable of type jstring named myString. I can convert it to an ANSI string as follows: const char* ansiString = env->GetStringUTFChars(myString, 0); is there a way of getting const wchar_t* unicodeString = ... ...

Way to read Windows EventLog with Java

Does anyone have any pointers on how to read the Windows EventLog without using JNI? Or if you have to use JNI, are there any good open-source libraries for doing so? ...

Memory footprint issues with JAVA, JNI, and C application

I have a piece of an application that is written in C, it spawns a JVM and uses JNI to interact with a Java application. My memory footprint via Process Explorer gets upto 1GB and runs out of memory. Now as far as I know it should be able to get upto 2GB. One thing I believe is that the memory the JVM is using isn't visible in the Pro...

UnsatisfiedLinkError: The specified procedure could not be found

I'm writing some JNI code in C++ to be called from an applet on Windows XP. I've been able to successfully run the applet and have the JNI library loaded and called, even going so far as having it call functions in other DLLs. I got this working by setting up the PATH system environment variable to include the directory all of my DLLs ...

Autoconf test for JNI include dir

I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to jni.h. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and g++ is available. Alternatively, is there a way to get javah (or a supp...

How to determine if a JNI (jogl) is available at runtime?

I'm working on a source-code visualization project that uses the Processing core library. The processing library has the option to use the jogl OpenGL library to render graphics which really improves performance. However, the JNI files that jogl uses aren't necessarily available at runtime, depending on who is using the project and on ...

How can I expose a C ODBC connection to a JVM using JNI?

I'm embedding a JRE in an existing C application using the invocation API, and I'd like to be able to use JDBC to work with the database in that code. This application is a transaction processing application, and the database transaction is managed by code in the C portion of the application, and the java code must run within that trans...

Monitoring memory usage for a C DLL called with Java via JNI?

How can I monitor the memory being used by a native C DLL that is being called from Java via JNI? Using standard Java monitoring tools and options I can see the Java memory space, but I cannot view any memory used by the C DLL. Java is using ~70MB, but the task in the Task Manager shows 200Mb+, and I'd like to see what's in that 130MB...

Accessing RPG on iSeries from Java

Has anyone had good experiences of talking direct to RPG programs running on a V5R4 iSeries machine from Java? If so, what are the recommendations of the community, and what pitfalls should I try to avoid? From the various pieces of literature and spike solutions I have attempted it looks as though we can use ProgramCallBeans (either th...

Open CDialog from Java using JNI

Hi everybody, I have an application that needs to open a CDialog written inside a DLL. The problem is that when DoModal() is called inside the DLL, the program crashes with: "Debug Assertion Failed!". Does anyone have any idea how can i get the CDialog opened? Thank you! ...

How do I create a symlink in Windows Vista?

I am looking to create symlinks (soft links) from Java on a Windows Vista/ 2008 machine. I'm happy with the idea that I need to call out to the JNI to do this. I am after help on the actual C code though. What is the appropriate system call to create the link? Pointers to some good documentation on this subject would be very much appreci...

How to create a JNIEnv mock in C/C++

I am writing some JNI code in C that I wish to test using cunit. In order to call the JNI functions, I need to create a valid JNIEnv struct. Does anyone know if there is a mocking framework for such a purpose, or who can give me some pointers on how to create a mock JNIEnv struct myself? ...

JNI memory management using the Invocation API

When I'm building a java object using JNI methods, in order to pass it in as a parameter to a java method I'm invoking using the JNI invocation API, how do I manage its memory? Here's what I am working with: I have a C object that has a destructor method that is more complex that free(). This C object is to be associated with a Java ...

Why does my JNI code not successfully find a jthrowable's getMessage method?

I'm trying to access the message in a jthrowable while handing an exception generated when I fail to find a class. However, I am unable to access the message ID of getMessage() on the jthrowable object, and I don't know why. I've tried changing the signature of getMessage to "()Ljava/lang/String" (without the semicolon at the end, but ...

Best way to throw exceptions in JNI code?

I'd like a consistent and simple way to throw exceptions in JNI code; something that handles chained exceptions (implicitly from the env->ExceptionOccurred method, or explicitly by parameters, either way is good) and saves me looking up constructors every time I want to do this. All of the above is preferably in C, although I could tran...