Reputation: 3229
I have this question before, but the problem is still not resolved. When running the code found below, the message "A JNI error has occurred, please check your installation...", etc. I have removed and reinstalled the jdk, making sure it was up to date. I reset the variable PATH but the same error still comes up.
package java;
public class javautilArrays {
public static void mian(String[] args) {
char[] copyFrom = {'d', 'd', 'c', 'a', 'f', 'f', 'e', 'n', 'a', 't', 'e', 'd'};
char[] copyTo = java.util.Arrays.copyOfRange(copyFrom, 2, 9);
System.out.println(new String(copyTo));
}
}
In the console terminal the following message appears:
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java
at java.lang.ClassLoader.preDefineClass(Unknown Source)
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.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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Upvotes: 1
Views: 4052
Reputation: 1971
Change the package name to something else. Make a new package and move this class to that package.
Upvotes: 0
Reputation: 2345
Do not use common names for your variables, methods and packages. look at the first line of your code
package java;
You have to change the name of your package to something else. You did not mention which IDE are you using to develop your program, but if you are using eclipse or netbeans you MUST recreate your project and delete this one.
In the above peace of code you have tried to add a new class to java package (native installation), which you are not allowed abviously since Java is not a OTF kind of compiler. Just change the package name from java to something else. If you take a look at the traceback you have attached,it's calling your project unknown source.
Do not forget to accept this answer if it worked.
good luck.
Iman
Upvotes: 1
Reputation: 5777
The error says "Prohibited package name: java" and if you look at the top of your code you see package java
. This is not a valid package name, you have to change it.
The error you mentioned is not in the stack trace.
Upvotes: 3