Doc_Schobs
Doc_Schobs

Reputation: 11

Java Applet SecurityException Prohibited package name: java

I'm very new to Java and i want to create a Java Applet. My .jar File is signed and the Package with .class ... is in the folder java (--> java.lal.class). But I got only this error:

SecurityException

Prhibited package name: java

Java Code:

package lal;
import java.applet.Applet;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;

public class lal extends Applet {

/**
 * @param args 
 * @throws JSONException
 */
  public static void main(String[] args) throws JSONException {
    String jsonStr = "SOME JSON DATA :) ";
    JSONObject jsonObj = new JSONObject(jsonStr);
    System.out.println(XML.toString(jsonObj));
  }

}

HTML Code:

<applet code="java.lal.class" width="700" height="750">
</applet>

Upvotes: 0

Views: 84

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168835

Since the code starts:

package lal;
import java.applet.Applet;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;

public class lal extends Applet { 
    // ...

That means the fully qualified class name is lal.lal where the first part is the package, and the second is the class name.

The code attribute of the applet HTML element should therefore be:

<applet code="lal.lal" width="700" height="750">
</applet>

Upvotes: 3

Amila
Amila

Reputation: 5213

Just like your error says, you're not allowed to use java in your package name for security reasons.

Just rename your package to something that doesn't contain reserved literals like java.

Upvotes: 0

Related Questions