0

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>
Doc_Schobs
  • 11
  • 3

2 Answers2

3

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>
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    @Doc_Schobs: Using [conventional names](http://stackoverflow.com/q/7155491/230513) can help make this easier to spot. – trashgod Sep 18 '15 at 15:29
0

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.

Amila
  • 5,195
  • 1
  • 27
  • 46