Java Applet and JNI

U

Uli Kunkel

I have a doSomething() method which is invoked by an applet button.
doSomething() calls a JNI dll native method.

Everything works ok until I got the need to call the doSomething() from
within a java script.

If I invoke doSomething() form javascript the code stops executing
somewhere in the JNI dll.
It just blocks and stops responding at a specific line in the dll.

The applet is signed and the blocking line is handling a camera device
via C++ SDK.


I would appreciate any suggestions.
 
J

jolz

I would try:
- checking behaviour with different browsers
- checking behaviour with different operating systems (especially
security with vista and windows 7 may cause problems)
- running browser as an administrator
- turning off browser's security features
- disabling plugins (I'd start with flash since it does know what camera is)

If it works directly from applet but doesn't work from javascript, after
trying different configurations you may find one where it does work from
javascript. Then it should be possible to find which exact difference in
working and not working configuration cause problems.
 
U

Uli Kunkel

jolz said:
I would try:
- checking behaviour with different browsers
- checking behaviour with different operating systems (especially
security with vista and windows 7 may cause problems)
- running browser as an administrator
- turning off browser's security features
- disabling plugins (I'd start with flash since it does know what camera
is)

If it works directly from applet but doesn't work from javascript, after
trying different configurations you may find one where it does work from
javascript. Then it should be possible to find which exact difference in
working and not working configuration cause problems.



Before I only tried with IE and Firefox.
I lowered the restrictions in IE, but the execution still blocks in the dll.
Anyway I tried Opera now and it works with default settings. :)

Now I have to see what is so different in IE and Firefox..
 
Ð

Филимон Лаковид

The listing below is of the obligatory hello world program. It is
different from what you have seen in your java primer though; Instead
of calling System.out.println(), it will call a C function. It is this
C function that will in print out the message.


package com.raditha.articles.jni;

public class NativeHelloWorld
{
public native void displayHelloWorld();


public static void main(String[] args) {
System.load(System.getProperty("user.home") +"/libhello.so");
new NativeHelloWorld().displayHelloWorld();
}
}


Notice the type modifier native? It tells the compiler that we are
calling a function in an external library. We use the load() method to
load the library containing our native code. The official java
tutorial uses the loadLibrary() call. The latter has a few pitfalls.
The first is that libraries on different platforms have different
naming conventions. These are not always obvious to java programmers.
The second issue is that loadLibrary() will only look in predefined
folders for the required library. That rules it it's usage with
applets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top