I am having the hardest time setting up IntelliJ 14 so I can use the libraries provided in an online course I am taking instructions. They provide two jar files
stdlib.jar and algs4.jar
each of which contains several java classes. There is also a data folder that contains text files called
/algs4-data
I created a new project and added these jar files into the
src
folder. Here is what that looks like
So I went into the Project Structure and added the libraries as shown in this screenshot
Now, all of the classes inside of the jar files include a main method which you should be able to call. The problem is that any time I try to run the main method in any of these classes I get an error. For example, typing in the IntelliJ terminal:
Guillermos-iMac:src guillermo$ java StdIn
Error: Could not find or load main class StdIn
This StdIn.java file is inside sodlib.jar and has a main method with the following
/** * Interactive test of basic functionality. */
public static void main(String[] args) {
System.out.println("Type a string: ");
String s = StdIn.readString();
System.out.println("Your string was: " + s);
System.out.println();
System.out.println("Type an int: ");
int a = StdIn.readInt();
System.out.println("Your int was: " + a);
System.out.println();
System.out.println("Type a boolean: ");
boolean b = StdIn.readBoolean();
System.out.println("Your boolean was: " + b);
System.out.println();
System.out.println("Type a double: ");
double c = StdIn.readDouble();
System.out.println("Your double was: " + c);
System.out.println();
}
Now, if I right click on the class itself and run it then I get this error popup
which when I choose the module then it runs. I want to be able to run the classes from the terminal so I can pass in arguments (mainly the .txt files in the data folder). I have spent hours trying to figure this out to no avail. Please help!