Running a Java program

I looked at some other SO issues, didn't find anything that solved my problem ... I have a Main.java file (below) and an OthelloLib.jar file without associated source files.

Startup javac Main.javafails

Main.java:8: cannot find symbol
symbol: class SimplePlayer
location: class Main
        OthelloPlayer p1 = new SimplePlayer ();
and a few more mistakes. SimplePlayer and BetterPlayer are defined in the bank. How do I talk about java about this bank? This command: javac -classpath .:OthelloLib.jar -g Main.javadoes not cause an error, but I still do not know how to start the program. If I run java -classpath .:OthelloLib.jar Main, java complains:

Exception in thread "main" java.lang.NoClassDefFoundError: TimeoutException

but TimeoutException.java is in the same directory as Main.java.

I don’t know where to look for basic Java material, like this!

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();
  }
}
+3
5

javac -classpath .:OthelloLib.jar Main.java

,

java -classpath .:OthelloLib.jar Main

-classpath .:OthelloLib.jar Java, SimplePlayer , ; , JAR . , , .

EDIT: , - TimeoutException, ... , TimeoutException.java? TimeoutException.class , Main.class?

+3

. IDE, , eclipse netbeans, . .

+2

Have you installed a link to OthelloLib.jar or a javacompiler call with the library as a parameter?

java -classpath .:OthelloLib.jar -g Main
+2
source

Have you imported all the libraries?

as

import a.b.c. OthelloPlayer;
+1
source

Did you indicate the class path when calling your program?

Perhaps something like the following:

java -cp .:OthelloLib.jar Main
0
source

Source: https://habr.com/ru/post/1717996/


All Articles