Skip to content

kaldun-tech/java-algorithms

Repository files navigation

java-algorithms

Working through algorithms course using Java

Compiling and running Java programs

Check JDK installation: javac -version

Compile Java file: javac YourProgram.java

Run the program: java YourProgram

Compiling with Princeton packages

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

Important options

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

Using Gradle

Set up Gradle: gradle init

Common Gradle Commands

  • ./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

Running Tests

Run All Tests

./gradlew test

Run Tests in a Specific Package

./gradlew test --tests "leetcode.*"

Run a Specific Test Class

./gradlew test --tests "leetcode.IntegerToRomanTest"

Run a Specific Test Method

./gradlew test --tests "leetcode.IntegerToRomanTest.testBasicConversions"

Run Custom Test Tasks

Run LeetCode Tests
./gradlew testLeetCode
Run BST Tests
./gradlew testBST

Project Structure

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

About

Working through algorithms course using Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published