Working through algorithms course using Java
Check JDK installation: javac -version
Compile Java file: javac YourProgram.java
Run the program: java YourProgram
Compile with the JAR in the classpath:
javac -cp C:\path\to\algs4.jar YourProgram.java
Run with the JAR in the classpath:
java -cp C:\path\to\algs4.jar YourProgram
Compile multiple files: javac File1.java File2.java
Specify output directory: javac -d bin YourProgram.java
Include external libraries: javac -cp lib/dependency.jar YourProgram.java
Set up Gradle: gradle init
./gradlew build
: Compiles, tests, and packages your code into a JAR file./gradlew tasks
: Lists all available tasks./gradlew assemble
: Assembles the outputs of the project./gradlew clean
: Deletes the build directory
./gradlew test
./gradlew test --tests "leetcode.*"
./gradlew test --tests "leetcode.IntegerToRomanTest"
./gradlew test --tests "leetcode.IntegerToRomanTest.testBasicConversions"
./gradlew testLeetCode
./gradlew testBST
This project follows standard Gradle conventions:
- Implementation classes:
src/main/java/[package]/
- Test classes:
src/test/java/[package]/
For example:
src/main/java/leetcode/IntegerToRoman.java
src/test/java/leetcode/IntegerToRomanTest.java