有两段代码: :)
TestAssert.java调用Assert.java
先使用set classpath 设置classpath
javac -d . Assert.java 正常
javac TestAssert.java就报错了
尝试了很多次都无功而返
最后将Assert.java放到了com.redrock.tools.debug目录下面,然后javac TestAssert.java正常。java TestAssert 也正常 :P
服了 :twisted: 。
//: Assert.java
// Assertion tool for debugging
package com.redrock.tools.debug;
public class Assert {
private static void perr(String msg) {
System.err.println(msg);
}
public final static void is_true(boolean exp) {
if(!exp) perr("Assertion failed");
}
public final static void is_false(boolean exp){
if(exp) perr("Assertion failed");
}
public final static void
is_true(boolean exp, String msg) {
if(!exp) perr("Assertion failed: " + msg);
}
public final static void
is_false(boolean exp, String msg) {
if(exp) perr("Assertion failed: " + msg);
}
} ///:~
//: TestAssert.java
// Demonstrating the assertion tool
//package c05;
// Comment the following, and uncomment the
// subsequent line to change assertion behavior:
import com.redrock.tools.debug.*;
public class TestAssert {
public static void main(String[] args) {
Assert.is_true((2 + 2) == 5);
Assert.is_false((1 + 1) == 2);
Assert.is_true((2 + 2) == 5, "2 + 2 == 5");
Assert.is_false((1 + 1) == 2, "1 +1 != 2");
}
} ///:~
TestAssert.java调用Assert.java
先使用set classpath 设置classpath
javac -d . Assert.java 正常
javac TestAssert.java就报错了
尝试了很多次都无功而返
最后将Assert.java放到了com.redrock.tools.debug目录下面,然后javac TestAssert.java正常。java TestAssert 也正常 :P
服了 :twisted: 。