java.lang.SecurityException: Prohibited package name: java.lang
It was tough looking it up on the internet. Usually, there are many postings about any one error message or exception. But not in this case. Actually, the explanation is quite accurate and helpful, providing that you believe it. It says that you've created a package called java.lang in your project, which is not allowed. nevertheless, you probably didn't mean to do that so you may be mystified by the description.
I suppose the villain of this particular piece is the otherwise-wonderful Eclipse. Eclipse allowed me to (inadvertently) create the java.lang package in my project when I sub-classed a class in java.lang. Many of those are final so can't be extended thus you won't often run into this problem (it's taken me about 16 years!). And in any case, the package only defaults to that of the sub-class when you click New in the type hierarchy window. In and of itself, having a java.lang package is not fatal. Eclipse will run it.
But if you create a jar file with that class in it, you cannot add the jar file to your class loader -- the exception mentioned above will be thrown.
OK, back to work!
No comments:
Post a Comment