C
c3411080
Unregistered / Unconfirmed
GUEST, unregistred user!
把类打包之后在另外一个类中引用可以顺利编译,当我用java解释时测试时却出错了,“Exception in thread "main" java.lang.NoClassDefFoundError: Line”,请问这是什么原因。
详细情况如下:
我先把一个类打包,放在C:/Javastuff/Geometry下
package Geometry;
public class Point {
public Point(double xval,double yval)
{
x=xval;
y=yval;
}
public Point(final Point apoint)
{
x=apoint.x;
y=apoint.y;
}
public void move(double xdelta,double ydelta)
{
x+=xdelta;
y+=ydelta;
}
publicdo
uble stance(final Point apoint)
{
return Math.sqrt((x-apoint.x)*(x-apoint.x)+(y-apoint.y)*(y-apoint.y));
}
privatedo
uble x;
privatedo
uble y;
}
然后我再定义一个类保存为Line
import Geometry.*;
public class Line {
public static void main(String args[])
{
Point ball3=new Point(2,2);
}
}
我用:C:/JAVA>javac -classpath "c:/Javastuff" Line.java可以顺利编译
当我用:C:/JAVA>java -classpath "c:/Javastuff" Line
却出错:Exception in thread "main" java.lang.NoClassDefFoundError: Line”,
详细情况如下:
我先把一个类打包,放在C:/Javastuff/Geometry下
package Geometry;
public class Point {
public Point(double xval,double yval)
{
x=xval;
y=yval;
}
public Point(final Point apoint)
{
x=apoint.x;
y=apoint.y;
}
public void move(double xdelta,double ydelta)
{
x+=xdelta;
y+=ydelta;
}
publicdo
uble stance(final Point apoint)
{
return Math.sqrt((x-apoint.x)*(x-apoint.x)+(y-apoint.y)*(y-apoint.y));
}
privatedo
uble x;
privatedo
uble y;
}
然后我再定义一个类保存为Line
import Geometry.*;
public class Line {
public static void main(String args[])
{
Point ball3=new Point(2,2);
}
}
我用:C:/JAVA>javac -classpath "c:/Javastuff" Line.java可以顺利编译
当我用:C:/JAVA>java -classpath "c:/Javastuff" Line
却出错:Exception in thread "main" java.lang.NoClassDefFoundError: Line”,