JNI Section Index | Page 12
How do I create a shared library with Borland C++?
Place your code in clib.cpp and use the following the command line(s):
C:JNI> bcc32 -c -Ic:javainclude -Ic:javaincludewin32 clib.cpp
C:JNI> bcc32 -tWD clib.obj
where c:java is the director...more
After passing an object to a native method, how do you access its member variables if they are arrays of primitives?
In Java, all arrays are objects. An array of characters is an Object and, in JNI, is represented as a jobject. Actually, JNI defines a jcharArray type to make usage a little bit more typesafe, but...more
Do C++ iostreams work from JNI functions?
It depends. We have been successful in using iostreams on Windows with all major JVMs (Sun, IBM, MS) and the Visual C++ compiler (5.0 and 6.0), but we have had trouble on Solaris with the g++ 2.95...more
How do I call a C function which takes a pointer as parameter from my Java program?
You need to store the pointer as an int or long on the Java side. You pass it to the native method as a primitive type and cast it to the appropriate pointer type once you're in C/C++.
How do I pass an array of primitives to a native method, like a char[]? And how do I define/access it from the C/C++ side?
In Java, all arrays are objects. An array of characters is an Object and, in JNI, is represented as a jobject. Actually, JNI defines a jcharArray type to make usage a little bit more typesafe, but...more
Is there an easy way to call C++ code from Java and the other way around?
The JunC++ion tool by Codemesh (http://www.codemesh.com) does just that.
JunC++ion has a code generator that generates C++ proxy classes for Java classes. These C++ proxy classes are usable like ...more
How can I access native methods using the Java Native Interface (JNI) from a J2ME application?
For both size and security reasons, JNI is not supported by the J2ME CLDC.
Information on the J2ME CLDC security model and
additional details related to this are available in the
CLDC specifica...more
Can I shut down my computer from a java application under Windows 95?
Microsoft has published the following articles:
Programmatically Force Windows 95 and Windows 98 to Log Off
Programmatically Restart or Log Off a Computer
Using code from the above articles, y...more
How do I communicate with a USB port from Java?
Short of writing a JNI library, there is no support for this from Java at this time. You can watch JSR 000080 to see if / when it becomes real.more
Should my application run with green threads or native threads if I'm writing JNI code?
For most JNI code, it doesn't matter. The exception is
if you are making any native calls associated with
threading - that is, calls to the pthread library
to create or manage threads. Then
you mu...more
How I can call a JNI method from a servlet? I have tried, but I received the error message " java.lang.UnsatisfiedLinkError: sincro ". (sincro is my JNI method.
How I can call a JNI method from a servlet? I have tried, but I received the error message "java.lang.UnsatisfiedLinkError: sincro". (sincro is my JNI method.)
My environment is:
OS - ...more
When you use System.loadLibrary("some dll"); from a trusted applet, where does Netscape look for the library?
It depends on the OS. With NT, you can copy your library into the user directory. With Windows 95, copy it to the windows directory. If you are using the Java plugin, copy it to the bin director...more
I have written my first RMI/JNI based sample program. I load the applet which gets the stub from the RMI server properly and when it invokes native methods in the remote object, the following error message is shown: "java.langAbstractMethodError". How can I fix this error?
Native methods should be called remotely. Define the native method as private and add a public helper function that calls this native method. Here's a snippet from an excellent article on JavaSoft...more
Can ADOs in the msado15.dll be used to build Java applications using Sun's JDK 1.3, or does it work only with the MS SDK or Visual J++?
There are many Java-COM bridges that can be used with Sun's JDK 1.3. Here's a list:
J-Integra from http://www.linar.com/
Brige2java from http://www.alphaworks.ibm.com/tech/bridge2java
Java2COM f...more
How do I prevent Swing components being drawn over by my JNI JAWT canvas? Normal AWT components are fine and draw over the top, but not my Swing version.
Swing controls are light-weight, which means that they don't have any native peers. Mixing AWT (heavy-weight) and Swing controls is not recommended by Sun. If you make sure that you place all Swin...more