package pack;
public class sample{
public static void main(String input[])
{
NumberFormat numberFormat = new DecimalFormat("#,##0.00##");
System.out.println(numberFormat.format(44533125.00));
}
}
代码在当前目录(c:/myprogram/)中工作正常。
然后我将sample.class文件复制并粘贴到其他目录(d:/myprogram),运行时出现错误,如下:
Exception in thread "main" java.lang.NoClassDefFoundError: sample (wrong name: pack/sample)
在Java中,.class文件可以在任何地方运行,对吗?但为什么我无法运行呢?