MENU

How to run Algs4 codes with IntelliJ IDEA on macOS

March 29, 2022 • Read: 921 • Algorithms

My environment : m1 MacBook Pro, macOS 12.3, Zulu JDK 1.8.0, IntelliJ IDEA 2021.3.1
  1. Download algs4.jar, algs4-data.zip, and Java source code
  2. Copy algs4.jar to /Library/Java/Extensions

    SCR-20220329-jkh

  3. Unzip algs4-data.zip to the folder where you store the source code
  4. Open IntelliJ IDEA, File->New->Project from Existing Sources... , choose the folder where you store the source code
  5. After you created the project , File->Project Structure..->Modules, add algs4.jar, ApplySCR-20220329-jwh
  6. 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!

    SCR-20220329-k7q

Archives QR Code
QR Code for this page
Tipping QR Code