• Post Reply Bookmark Topic Watch Topic
  • New Topic

SecurityException: Prohibited package name  RSS feed

 
Prasma Kankut
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anything wrong with the following method? It is throwing java.lang.SecurityException: Prohibited package name: java.lang.

Here is the full stack trace.

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.lang
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Thanks.
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't suppose you have a package statement at the beginning of your java file?
 
Prasma Kankut
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. There is no package statement.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible to get this kind of error if you're using an old JDK that doesn't include some newer API class, but then you put a newer JDK's rt.jar (which does include that class) on the CLASSPATH. The old JDK will become very unhappy upon loading a java.lang.Something class from the CLASSPATH instead of from the boot class loader. Check to see if your CLASSPATH includes any rt.jar's -- it's never appropriate to include them.
Although I think this can only happen when there's a SecurityManager present: JaveWebStart, Applets, RMI, etc.
 
Prasma Kankut
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest, you got it right! Looks like it was the Oracle client which did the mischief.
But I can't get your point about the SecurityManager. Do you say this error will occur only when using Applets, RMI etc? But mine is a simple Java application.
Also, I noted another thing - this error occurs only when I use the java.util.regex package. Else everything is fine.
Does it mean that, the old JDK don't have this package and hence the error?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!