Java编程思想第4版中的一个例子, 为何不能运行?
执行时一直挂在那,没输出。PS D:\java\source> javac annotations/AtUnitExample1.java
PS D:\java\source> java annotations/AtUnitExample1
//: annotations/AtUnitExample1.java
package annotations;
import net.mindview.atunit.*;
import net.mindview.util.*;public class AtUnitExample1 {
  public String methodOne() {
    return "This is methodOne";
  }
  public int methodTwo() {
    System.out.println("This is methodTwo");
    return 2;
  }
  @Test boolean methodOneTest() {
    return methodOne().equals("This is methodOne");
  }
  @Test boolean m2() { return methodTwo() == 2; }
  @Test private boolean m3() { return true; }
  // Shows output for failure:
  @Test boolean failureTest() { return false; }
  @Test boolean anotherDisappointment() { return false; }
  public static void main(String[] args) throws Exception {
    OSExecute.command(
      "java net.mindview.atunit.AtUnit AtUnitExample1");
  }
} /* Output:
annotations.AtUnitExample1
  . methodOneTest
  . m2 This is methodTwo  . m3
  . failureTest (failed)
  . anotherDisappointment (failed)
(5 tests)>>> 2 FAILURES <<<
  annotations.AtUnitExample1: failureTest
  annotations.AtUnitExample1: anotherDisappointment
*///:~

解决方案 »

  1.   

    失望啊,没人回答。
    不过现在本人已经解决了,在这里说一下。这个程序要用到作者个人的包,在程序的开头已有说明:
    import net.mindview.atunit.*;
    import net.mindview.util.*;
    把这些包放在执行工作路径下,这个应该不是问题,我遇到问题时这些都做过。解决问题是这下面:
    1. 编译用到的类: PS D:\java\source> javac net\mindview\atunit\AtUnit.java
    2. 在annotations/AtUnitExample1.java程序中的main()方法的内容改一下,也就是类名AtUnitExample1加上路径:
          OSExecute.command("java net.mindview.atunit.AtUnit annotations/AtUnitExample1");我还没想明白为什么第2步是必要的。
      

  2.   

    不会用IDE。
    现在是学基本的东西,简单的程序,用IDE感觉更复杂了,还得学IDE。想了很长时间都没法解决才到这来求助的,还好,后来解决了。
      

  3.   

    java annotations/AtUnitExample1这里不是很清楚吗?
      

  4.   

    开始的时候手巧很有好处的,不过都后来的时候还是用IDE方便一些。
    不然出错的话很难找的。