Java Arena

Pro Track

Projects for your own computer, built with the tools Java programmers use every day: a JDK 21, Maven and JUnit 5 tests. Each one is a few hours of work, for after the course.

These projects run on your computer, not on this site. Java Arena can't see your code or your test results and doesn't grade anything: the project's tests tell you when it works. The checklist on each project's page is yours to tick.

The projects

  • Word statistics on the command line

    A small command-line program that reads text files and tells you how many lines, words and characters they have, and which words come up most often. You build it with Maven and check it with JUnit 5 tests, on your own computer.

    About 3 to 5 hours. A checklist of 9 items to tick as you go.

  • A yarn stash with JDBC and H2

    A small program for knitters that keeps track of their yarn in a real database. You write the data access object (DAO) that creates the table and adds, finds, changes and removes rows with JDBC and H2, and JUnit tests check it against a fresh database in memory.

    About 3 to 5 hours. A checklist of 8 items to tick as you go.

  • Tide pool pairs: a JavaFX memory game

    A memory game in a JavaFX window: sixteen cards lie face down, and you flip two at a time to find the pairs. You write the game's rules in plain Java classes that JUnit 5 tests without a window, then connect them to the window, and Maven runs both on your own computer.

    About 3 to 5 hours. A checklist of 9 items to tick as you go.

What you need

  • A computer with Windows, macOS or Linux. A phone or a tablet isn't enough for these projects: you write and run them on the computer.
  • A JDK 21 (the Java Development Kit: the compiler and the Java virtual machine).
  • Maven, which downloads the libraries a project uses (such as JUnit) and runs its tests. IntelliJ IDEA, Eclipse and NetBeans have Maven built in; VS Code needs Maven installed to run Maven's commands.

Set up your computer

  1. Install a JDK 21. Eclipse Temurin is free: on adoptium.net (opens in a new tab), choose version 21 and your system, and run the installer (for Windows and macOS). On Linux, use your package manager (on Ubuntu 22.04 or newer, sudo apt install openjdk-21-jdk; on Fedora, sudo dnf install java-21-openjdk-devel), or unpack the .tar.gz from adoptium.net and add its bin folder to your PATH.
  2. Install Maven: download it from maven.apache.org (opens in a new tab) and follow its installation steps (opens in a new tab) (unzip it and add its bin folder to your PATH), as you do on Windows. On macOS with Homebrew, brew install maven does it; on Ubuntu, sudo apt install maven. Or skip this step and use an IDE that has Maven built in.
  3. Check both in a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux). Each prints its version: Java should say 21, and Maven should name Java 21 too. If Maven names another Java (a package manager's Maven can bring its own), set JAVA_HOME to your JDK 21's folder. If you skipped step 2 and use an IDE's Maven, mvn isn't on your PATH: check only java -version, and run the tests from the IDE.
    Commands for your own computer
    java -version
    mvn -version
  4. Download a project's zip from its page, unzip it, and run its tests in the project's folder. The first run downloads JUnit and Maven's plugins, so it needs a connection and takes a minute or two. The tests fail at first: they are your to-do list.
    Commands for your own computer
    cd PROJECT-FOLDER
    mvn test

In an IDE, open the project's folder (or its pom.xml) as a project, and run the tests from the IDE's Maven panel or by right-clicking the src/test/java folder.

Put a project on GitHub (optional)

Each project has a GitHub Actions workflow (.github/workflows/test.yml): in your own GitHub repository, GitHub runs the tests on its computers every time you push. The results are in your repository, for you to see; Java Arena never sees them.

  1. Sign in to GitHub (opens in a new tab) (an account is free) and create a new repository, public or private, without a README.
  2. Put the project's files in it, with Git or in the browser:
    • With Git on your computer, in the project's folder:
      Commands for your own computer
      git init
      git add .
      git commit -m "Start the project"
      git branch -M main
      git remote add origin https://github.com/YOUR-NAME/YOUR-REPOSITORY.git
      git push -u origin main
      You need Git for this: get it from git-scm.com (opens in a new tab) or your package manager. The first time, tell it your name and email, or git commit stops with "Author identity unknown":
      Commands for your own computer
      git config --global user.name "Your Name"
      git config --global user.email you@example.com
      The first git push asks you to sign in, and GitHub doesn't accept your account password there. Git for Windows opens a browser window to sign you in. On macOS and Linux, sign in first with GitHub CLI (opens in a new tab) (gh auth login), or paste a personal access token when Git asks for the password. GitHub Desktop (opens in a new tab) signs you in for you, too.
    • In the browser: on the new repository's page, choose uploading an existing file, drag in everything inside the unzipped folder, then Commit changes. Don't upload target/. Check that the .github folder comes too: some file browsers hide folders whose names start with a dot (on macOS, Cmd+Shift+. in Finder shows them; on Linux, Ctrl+H in most file managers). Later uploads, once the repository has files, go through Add file, then Upload files.
  3. Open the repository's Actions tab. The workflow Tests runs mvn -B test: a red cross means some tests fail (open the run to see which), a green check means they all pass. Each push runs it again.

On a phone, github.com in the browser and the GitHub mobile app both show your repository, its code and the Actions tab with each run's result. You can even fix a small thing in github.com's editor on the phone; the commit runs the tests again. Writing the project and running mvn test yourself need the computer.