我查看了其他一些 SO 问题,没有找到任何可以解决我的问题的内容...我有一个 Main.java 文件(如下)和一个 OthelloLib.jar 文件,没有关联的源文件。
Running javac Main.java
失败了
Main.java:8: cannot find symbol
symbol : class SimplePlayer
location: class Main
OthelloPlayer p1 = new SimplePlayer();
and a few more errors. SimplePlayer and BetterPlayer are defined in the jar. How do I tell java about this jar? This command:
javac -classpath .:OthelloLib.jar -g Main.java
doesn't cause an error, but I still don't know how to run the program. If I run
java -classpath .:OthelloLib.jar Main
, java complains:
Exception in thread "main" java.lang.NoClassDefFoundError: TimeoutException
但 TimeoutException.java 与 Main.java 位于同一目录中。
我不知道在哪里可以找到像这样的基本 Java 内容,所以我在这里!
public class Main {
public Main() { }
public static void main(String[] args) {
OthelloPlayer p1 = new SimplePlayer();
OthelloPlayer p2 = new BetterPlayer();
OthelloObserver o = new OthelloSimObserver();
// Create an untimed game
OthelloGame g = new OthelloGame(p1, p2, o);
System.out.println("Starting game");
g.run();
}
}