🧰 Environment Setup & IDE Tips
This note documents the setup process for the Princeton Algorithms course.
It uses Linux with IntelliJ IDEA and the algs4.jar library.
It also captures key lessons from debugging the first assignment.
💡 IntelliJ IDEA: What Not to Do
- ❌ Do not click “New Project” — this is meant for advanced configurations.
- ✅ Always use “Open” and select the entire project folder, not individual
.javafiles. - 🧭 Use the provided project zip from Lift Setup Guide to ensure correct structure and classpath.
🧭 What Happened During Setup
-
Missing Libraries at Compile Time
Attempted to compileBarnsley.javausingjavac-introcs, but got import errors forStdDrawandStdRandom.
➤ Cause:algs4.jarwas missing from the classpath. -
Located
algs4.jar
Found inside/usr/local/lift/lib/, confirming the Lift installer worked. -
Patched Compile-Time Script
Edited/usr/local/bin/javac-introcsto includealgs4.jarin theCLASSPATH. -
Runtime Error:
NoClassDefFoundError
Compilation succeeded, but running withjava-introcsfailed due to missing runtime classpath. -
Patched Runtime Script
Edited/usr/local/bin/java-introcssimilarly to includealgs4.jar.
📦 Assignment 0: Hello, World
Based on Assignment Spec:
- Write
HelloWorld.javaandHelloGoodbye.javato test basic compilation and command-line arguments. - Use
RandomWord.javato testStdIn,StdOut, andStdRandomfromalgs4.jar. -
Compile using:
javac-introcs HelloWorld.java -
Run using:
java-introcs HelloWorld
🔗 Solution: HelloWorld.java
See the solution file in the repository: HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
🧪 Verification Checklist
- ✅ Java 11 installed (
java -version) - ✅
algs4.jaraccessible in/usr/local/lift/lib/ - ✅ IntelliJ configured with correct SDK and project folder
- ✅
javac-introcsandjava-introcspatched with correct classpath
📚 References
This note is part of the
structs-algos-unixseries and will be auto-synced to My Portfolio using thenetlify-build.shscript.
