这是package问题吗?
usehello.java如下:
import java.user.hello;
public class usehello{
public static void main(String [] args){
hello he = new hello();
he.jout();
}
}
hello.java如下:
package java.user;
public class hello {
public void jout() {
System.out.println( "hello world ");
}
}
编译hello.java,把hello.class拷贝到当前目录\java\user下。
编译usehello,java,运行,出现下面异常:
---------- java excute ----------
Exception in thread "main "
java.lang.SecurityException: Prohibited package name: java.user
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:479)
at java.lang.ClassLoader.defineClass(ClassLoader.java:614)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at usehello.main(usehello.java:4)
Output completed (0 sec consumed) - Normal Termination
请问这是什么原因造成的?
环境WinXP SP2 JAVASE1.6.0_01-b06
------解决方案--------------------Prohibited package name: java.user
你这个包名是禁止的,换个其他的包名,着么可以用JAVA.社么?