My environment : m1 MacBook Pro, macOS 12.3, Zulu JDK 1.8.0, IntelliJ IDEA 2021.3.1
- Download algs4.jar, algs4-data.zip, and Java source code
Copy algs4.jar to /Library/Java/Extensions
- Unzip algs4-data.zip to the folder where you store the source code
- Open IntelliJ IDEA, File->New->Project from Existing Sources... , choose the folder where you store the source code
- After you created the project , File->Project Structure..->Modules, add algs4.jar, Apply
Now you can compile and run the sample code in the terminal in idea using the following command, e.g. BinarySearch.java
javac BinarySearch.java java edu.princeton.cs.algs4.BinarySearch tinyW.txt < tinyT.txt
If you can see the same running result as in the picture, congratulations!