当前位置: 技术问答>java相关
JAVA运行错误?帮帮小弟!
来源: 互联网 发布时间:2015-07-11
本文导语: 出错信息如下: E:SourceAndDocZAX>java Test Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: ZAX/Test) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.ja...
出错信息如下:
E:SourceAndDocZAX>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: ZAX/Test)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(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:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
E:SourceAndDocZAX>
源码如下:
public class Test {
/**
* Constructor
*/
public Test(Zax zax,String[] args) {
Frame frame = new TestFrame(zax,args);
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
frame.setVisible(true);
}
/**
* main
* @param args 传送文件的目标IP地址
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
new Test(new Zax(),args);
}
}
请高手指教,不胜感激!
E:SourceAndDocZAX>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: ZAX/Test)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(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:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
E:SourceAndDocZAX>
源码如下:
public class Test {
/**
* Constructor
*/
public Test(Zax zax,String[] args) {
Frame frame = new TestFrame(zax,args);
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
frame.setVisible(true);
}
/**
* main
* @param args 传送文件的目标IP地址
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
new Test(new Zax(),args);
}
}
请高手指教,不胜感激!
|
E:SourceAndDocZAX>java Test
改为
E:SourceAndDoc>java ZAX.Test0D
--- ZJQ
改为
E:SourceAndDoc>java ZAX.Test0D
--- ZJQ
|
是因为找不到Zax这个类把
==================
别忘给分啊:))))))
==================
==================
别忘给分啊:))))))
==================
|
为什么一个包都不用import的,至少也应该有javax.swing.*、java.awt.*和java.awt.event.*吧?
否则怎么出Frame出来?
否则怎么出Frame出来?
|
是不是沒將SystemLookAndFeelClass所在的包import