Date: Fri, 14 Aug 1998 10:48:52 +0200
From: Nathalie MARC <Nathalie.Marc@toulouse.inra.fr>
To: java-security@java.sun.com
Subject: Java Security Exeption
I read with interest the page "Frequently Asked Questions - Java
Security".
On paragraph 15 "Summary of applets capabilities", you write that an
applet loaded from the local file system and executed through
Appletviewer JDK1.x or an unsigned applet loaded from the local file
system and executed through Netscape Navigator 4.x, can load library.
I try to run a very easy applet, wich loads a shared library, on
JDK1.1.4 appletviewer (solaris).
Java source code is in my local disk and applet runs on my disk.
I get a security exeption. I don't understand why.
Can you help me ?
Thank you.
Nathalie MARC
Here, the source code :
--------------- Hello.java -----------------
/**
* Appel d'une methode native C =E0 partir d'une applet JAVA
* (utilisation JNI)
**/
import java.applet.Applet;
import java.awt.*;
public class Hello extends Applet {
public native void displayHello();
static {
try {
System.loadLibrary("helloa");
}
catch(Exception ex) {
ex.printStackTrace();
}
}
Label helloLabel =3D new Label ("Hello, you're looking at me ?");
public void init() {
displayHello();
add (helloLabel);
}
}
----------------- Hello.h ------------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Hello */
#ifndef _Included_Hello
#define _Included_Hello
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Hello
* Method: displayHello
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_Hello_displayHello
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
--------------- Hello.c -----------------
#include <jni.h>
#include "Hello.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_Hello_displayHello(JNIEnv *env, jobject obj)
{
printf("Hello world!\n");
return;
}
-----------------------------------------------------------------
Here the error message :
appletviewer Hello.html
sun.applet.AppletSecurityException: checklink
at sun.applet.AppletSecurity.checkLink(AppletSecurity.java:250)
at java.lang.Runtime.loadLibrary(Runtime.java)
at java.lang.System.loadLibrary(System.java)
at Hello.<clinit>(Hello.java:12)
at java.lang.ClassLoader.resolveClass(ClassLoader.java)
at
sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:278)
at
sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:354)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:462)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:398)
at sun.applet.AppletPanel.run(AppletPanel.java:237)
at java.lang.Thread.run(Thread.java)
java.lang.UnsatisfiedLinkError: displayHello
at Hello.init(Hello.java:22)
at sun.applet.AppletPanel.run(AppletPanel.java:287)
at java.lang.Thread.run(Thread.java)