当前位置: 代码迷 >> J2SE >> 运行不了?咋回事
  详细解决方案

运行不了?咋回事

热度:443   发布时间:2016-04-24 13:01:15.0
运行不了????怎么回事?

Java code
public class PassReference{    public static void main(String[] ar)    {        Test c = new Test();        System.out.println("在调用方法inceptReference()之前,c.a的值为:" + c.a);        inceptReference(c);        System.out.println("在调用方法inceptReference()之后,c.a的值为:" + c.a);    }    static void inceptReference(Test t)    {        System.out.println("The first value of t.a is:" + t.a);        t.a++;        System.out.println("The second value of t.a is:" + t.a);    }}class Test{    public int a = 0;}

运行结果如下:
java.lang.NoClassDefFoundError: PassReference
Exception in thread "main"

------解决方案--------------------

------解决方案--------------------
你编译没?
javac PassReference.java
java PassReference
------解决方案--------------------
我这里可以运行的,可能你没有编译,编译好了运行PassReference.class文件。
------解决方案--------------------
CLASSPATH加入当前路径:.;
------解决方案--------------------
没有编译啊~啊~啊~啊~啊~啊~啊~啊~
------解决方案--------------------
编译了吗???????
------解决方案--------------------
这个异常告诉你 没有找到要运行的类

你应当先编译 javac PassReference.java 
在运行 java Passreference.java
------解决方案--------------------
呀 打错 运行时是 java Passreference
没.java 
呵呵
  相关解决方案