jni

Swing transparency using JNI

I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button instead of a JButton it ...

Anyone know how to use WMI with C instead of C++ ?

I'd hate to have to relearn C++ just for this! Any libraries/URLs would be great and yes, Google didn't help much here :-( This is for an upcoming project in which my product (Java based) would provide support for Microsoft's Hyper-V virtualization platform. Unlike VMware, which provides a Web-service, the Hyper-V APIs are mere extensi...

How to automatically copy data to new RMI threads ?

Hello, I am adapting a little rmi client-server application. I have written several things : HelloInterface -> A Hello World interface for RMI Server -> The server app' Client -> The client app' Nothing special, but... I have put my hands in a new RMISecurityManager, which calls a JNI method and checks the permission for a separate us...

How do I redirect terminal output from a C program to System.out with JNI?

I am invoking a C library via JNI that prints to stdout. How can I redirect this output to System.out? ...

Calling a JNI modal dialog disables taskbar icon.

In a Java application (JRE 1.5.0_12) on Windows XP, I call a native method: public native int attachImage( ... ); ... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this window has focus. This is an issue because when this wind...

How to know if is Applet or Application

I have this code inside a class that is used by an application and by an applet. static { if (System.getProperty("os.name").startsWith("Windows")) { System.loadLibrary("extmapi"); } Unfortunately, when the applet loads this code I get an error, because it can't load the "extmapi" library. To avoid this erro...

What is the 'correct' way to store a native pointer inside a Java object?

What is the 'correct' way to store a native pointer inside a Java object? I could treat the pointer as a Java int, if I happen to know that native pointers are <= 32 bits in size, or a Java long if I happen to know that native pointers are <= 64 bits in size. But is there a better or cleaner way to do this? Edit: Returning a native poi...

Possible to duplicate current java stack using JNI

I am trying to record the arguments passed to a method before it is called using bytecode instrumentation. Currently while instrumenting using java code I have to first pop all the args into a locals, then push them again twice (once for my method which will record and in this case all primitive types have to be converted to their boxe...

Using JNI to retrieve outlook contacts

Hi all, I need to retrieve the list of contacts (and only them) from any Outlook application except Outlook Express. I've seen many different libraries that can solve my problem but any of them is opensource. I was wondering if it is worth to solve this problem from scratch using JNI. I have never developed using this framework; have yo...

debug a dll from java java->jni.dll ->app.dll -> app.dll

how can I debug a dll that is not loaded by the java application. The scenario is this: my java app is loading the jni.dll that is using another dll and that dll is using another dll. java<->jni.dll<->dll<->dll I have the source code for all modules I am using visual studio express when debugging the jni.dll but what should I do to ...

Java I/O using inpout32.dll

I am trying to control some LEDs wired to the parallel port on Windows XP. The easiest solution would be Inpout32.dll from Logix4u.net. I have found many source code samples in various languages (C++, Visual Basic, C#) but nothing using Java. Do you know any tutorials about calling DLL functions from Java ? (what I have found so far on ...

possible java JNA issue

my java UI unexpectly terminated and dumped a hs_err_pid file. The file says "The crash happened outside the Java Virtual Machine in native code." So JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the error file below. ...

In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?

In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed. It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this? I need this to call the Win32 GetWindowLong and SetWindowLong API calls, which can be done via the Ja...

Memory footprint for C JNI increases even after freeing memory in code

I have created C shared object which is invoked using JNI, when I checked the memory footprint it keeps on increasing, and never reduces. But the memory is being being freed in C code, is there any way to overcome this behaviour of JNI. The memory footprint increases up to 2 GB and process gets killed. ...

Usefulness of JNI

I've been a java developer for a couple years and have heard that you can do some pretty useful and powerful things with JNI. I don't know if I just haven't needed to use it or if it isn't terribly relevant to me; but I have not had to touch it at all. I am wondering what the usefulness of this aspect of Java is. Examples would be grea...

NetBeans Library using JNI

Can I have a Library defined that makes use of JNI in NetBeans? Seems the library definition only allows Jars or Folders. How can I assure that the DLL follows the jar file when the app is built? ...

Where to install local Java libraries by default?

I'm integrating JNI bindings with a C++ library. The library follows the usual conventions: the installation root is /usr/local by default and can be modified with the --prefix argument to ./configure; the .a or .so files go in ${prefix}/lib; etc. The JNI binding produces two new libraries, libfoojni.so (the native part) and libfoo.jar...

Running a JNI application in the Sun VM under Valgrind

The sun JVM spits out a LOT of extra noise when run under valgrind, which makes tracking memory problems in the application very challenging. I'd like to find either a suppression file, or a VM runtime mode, that will strip out spurious memory errors in order to separate the wheat from the chaff in this situation. Any suggestions? ...

How to: Java listening for events captured by C thread.

I would like to create a Java program to listen for and respond to events captured by a thread in C. Can someone explain how this can be achieved using JNI, or point me to online tutorials? Thank you. ...

How can I profile a JNI application using the Eclipse TPTP?

I need to profile a java application launched by the JNI invocation API from a C application, and naturally the TPTP tools seemed like a good place to start. However, I can start the application, but I have no idea how to connect to it for profiling. I realize this falls into the 'dumb newbie' bucket, but I really am kind of lost. Per...