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)
<i>The fact that today we know more than yesterday is good news about today, not bad news about yesterday - Ilja Preuss</i>
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.
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?