Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java Applet and JNI

1 view
Skip to first unread message

Uli Kunkel

unread,
Nov 12, 2009, 4:33:03 AM11/12/09
to
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.

jolz

unread,
Nov 12, 2009, 11:55:09 AM11/12/09
to
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.

Uli Kunkel

unread,
Nov 19, 2009, 4:27:54 AM11/19/09
to

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..

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

unread,
Nov 24, 2009, 7:11:12 AM11/24/09
to
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.

0 new messages