To run the code for your challenge locally, you’ll need java & mvn installed. Our test runners use Java 21 (as of November 2023).The script for your challenge (like ./your_bittorrent.sh) will automatically compile your code using mvn before executing it. It’ll
look something like this:
When running tests on our servers, the mvn command will only be run once and then commented out. This ensures that each test only runs the java -jar ... line.
You can add more files and directories to src/main/java. The test runner will include them when compiling your code.For example, if you added a file at src/main/java/Foo.java, you could use it like so:
Copy
Ask AI
public class Main { public static void main(String[] args) { Foo.foo(); // calls the method foo() from Foo class in Foo.java }}
By default, all files in src/main/java are in the default package. If you want to extract files into a different package,
you’ll need to add a package declaration to the top of the file and change its location. Here’s what that’d look like:Let’s say you wanted to extract Foo.java into the com.example package. Store Foo.java at src/main/java/com/example/Foo.java and add the following lines:
Copy
Ask AI
package com.examplepublic class Foo { public static void foo() { System.out.println("Hello world!"); }}
Use an IDE like IntelliJ IDEA which will automatically offer to move your file
to a directory matching the package name.
You can add dependencies to your project by adding them to your pom.xml file.For example, to add the gson library, add the following to the <dependencies> section in your pom.xml: