jni

JNI Performance

Our main program is in java but the code that extracts our data from storage is written in C. I need to build an HDF5 file from extracted data. Would it be better to use JNI to call the C code to get the data and then build the HDF5 file from Java or to build the HDF5 from the C code? I have little experience with JNI or C. Also One o...

Passing large C structure through JNI efficiently

I have a large C structure (about 40 members, int and char[]) which I have to pass through JNI to the Java side for further processing. This happens repeatedly. (I already put the GetMethodID() etc. into an init() function on the C side so I only have to call them once.) What would be an efficient way to do this? I can think of: Inst...

Writing to std out from Java JNI DLL - output only appear when application exits

We're writing a JNI DLL to wrap a third-party DLL. In our DLL, we're writing debug statements to standard out. When we use the DLL from our Java application, nothing gets printed to the Java console during the application execution. When the application is closed, all the output from the DLL gets written to the Java console. We'd like ...

Loading a universal binary with Java

Hi Everyone, I have an Java applet that loads native code through JNI. Everything worked just fine until I made the upgrade to Snow Leopard, and then Safari decided to be dumb. It turns out Safari will only load 64 bit binaries when in 64 bit mode. (You can put it in 32 bit mode, but that is not an option.) I changed my build system (g++...

Closing db file when using Tokyo Cabinets Java bindings

I'm writing a small Java-based server around Tokyo Cabinets JNI-bindings, and I am a bit confused regarding opening and closing of the db file. The server is multi-threaded, and I'm therefore wondering if it is best to open the db file upon start-up and then let the threads use get/put unsynchronized (I think that the tokyo docs state th...

How to return array from JNI to java?

Hello, I am a beginner programmer and I am attempting to use the android NDK. Is there a way to return an array (in my case an int[]) created in JNI to java? If so, please provide a quick example of the JNI function that would do this. -Thanks ...

What's the best way of getting the results of GetLastError() after a WinAPI call into a nice char* ?

I'm writing a DLL which a java program uses to call the WinAPI in various ways. I want to throw proper exceptions back to java but I need a nicely formated WinAPI error not just the int that get's returned from GetLastError(). I'm sure there's a nice way to do it. ...

How to get text indent (tabs) from some text input?

For example, suppose I'm editing following text (\t is for tabs, it's not text) '\t\t\tSome text...' and my input keyboard position is right before 'S' (there is no selected text) and I want to get number of tabs before 'S' (in this case it's 3) So how to get that number of tabs using Win32 API? p.s. Maybe some function to get whole cu...

Developing JNI applications with Eclipse (Combined Java/C++)

Hello. Have anyone successfully managed to setup a combined Java/C++ project for Eclipse? What I am trying to do is quite simple; 1) Compile my Java sources 2) Run Javah to create the JNI interface 3) Compile all the C/C++ sources 4) Link native shared library + package the JAR Hints or even real projects which work are much welcome....

Can I mix JNI headers implementation with normal C++ classes?

If I try to implement my class on this file I get an error UnsatisfiedLinkError, however if I remove the implementation of the Broker.h Class it goes ok. Why? Broker.h #include "XletTable.h" #ifndef BROKER_H_ #define BROKER_H_ class Broker { private: static Broker* brokerSingleton; static XletTable *table; // Private con...

Passing pointers between C and Java through JNI

At the moment, i'm trying to create a Java-application which uses CUDA-functionality. The connection between CUDA and Java works fine, but i've got another problem and wanted to ask, if my thoughts about it are correct. When i call a native function from Java, i pass some data to it, the functions calculates something and returns a resu...

How to implement a Google-chrome-like title bar for Java SWT application

I have inherited development of a Java/SWT application running on Windows only. One of the feature requests that I need to scope is a Google-chrome-type title bar in place of the SWT windows title bar. The application's tabs appear at the same level as the window control buttons. My understanding is that I will need to: write a Win...

Is there a cross platform way of handling named pipes in Java or should I write my own?

I'm writing a bit of JNI code where a DLL running in the process space of various processes on the system needs to talk back to a java process. I've decided to use named pipes to do this (for various reasons) after weighing up shared mem/sockets/rpc etc. My question is, is there a nice way of handling named pipes in Java or should I wr...

Is it possible to generate a DLL using Turbo C/C++ compiler ??

I need this for calling a C function from Java class (JNI) and I know that there are options to do this using "Microsoft Visual C++ compiler". (explained here) But I am interested to know if something similar can be done using TC or TCC. I don't have a copy of "Microsoft Visual C++" and not sure if cl.exe is available without having to...

Wrapping an existing application with JNI

Most of the documentation that details how to get started with JNI described how to build a new JNI application using X-Code. Can anyone link me to a description of how to use JNI to interface with Objective-C in an existing application. ...

Does Java pass by reference or value to C when using JNI ( more specifically Android NDK)

Does Java pass by reference or value to C when using JNI ( more specifically Android NDK) ...

Returning a C++ class to Java via JNI

Hello, I'm currently using both C++ and Java in a project and I'd like to be able to send an object which is contained in C++ to my Java interface in order to modify it via a GUI and then send the modification back in C++. So far I've been returning either nothing, an int or a boolean to Java via the JNI interface. This time I have to ...

Calling a DLL from an Applet via JNI

I have a "proof of concept" piece of work that crosses over into some unfamiliar territory. I'm tasked with connecting an EFTPOS machine to an application running as an applet in a browser on our intranet. I've ignored the EFTPOS dll for the moment and created a simple JNI decorated DLL in my language of choice (Delphi) that just logs a...

Java JNI stackfall prevention

I use Java JNI with Gdal. There are some server side applications built on top of the JNI bindings. The whole JVM stackfalls if there is an error in the JNI section. What's the best way of testing that a c/c++ library does not contain fatal errors which will cause JVM stackfall ? What is the best practice to cleanly deal with errors whi...

how to set java library path for processing

Hi, I'm using pde to run a processing app , and I got the following error : "Verify that the java.library.path property is correctly set" . could anyone of you tells me how to solve this problem ? thanks in advance . ...