1.6. Java Web Dev Exercises

1.6.1. Initial Setup

The steps here will walk you through setting up the repository that you’ll use to study example code, work on studios, and complete your first assignment of this unit.

  1. Create a Fork of LaunchCodeEducation/java-web-dev-exercises. Do not clone and create a local version of this repo just yet.

  2. Open IntelliJ.


    If the app opens up to an existing project, simply close that window to return to the welcome screen.

    If you prefer to have IntelliJ NOT open your most recent project:

    1. Mac users: Select IntelliJ > Preferences > Appearance & Behavior > System Settings and un-check Reopen projects on startup.

    2. Windows users: Use File > Settings > Appearance & Behavior > System Settings.

  3. The Welcome to IntelliJ dialog looks different now. It includes a list of your most recent projects. However, we have the same three options in the upper-right corner. Select Get from VCS.

    IntelliJ VCS button

    Clone a repository from a version control system.

  4. Select the GitHub option on the left side of the next window. Click Log In via GitHub or Use token and follow the on-screen prompts.

    IntelliJ login to GitHub button

    Set up IntelliJ to talk to your GitHub account.


    To work with a remote repository in IntelliJ, you need to configure the program to access your GitHub account. We recommend authenticating your account using a token. This takes only one brief extra step, and will prevent you from having to update IntelliJ settings whenever you change your GitHub password.

  5. Now return to the Repository URL tab. From the URL dropdown options, select your fork of java-web-dev-exercises, along with an appropriate destination directory (like the folder where you’ve stored other projects for this class).

    When ready, click the Clone button!

    IntelliJ Repo Selection

    IntelliJ Repo Selection

  6. If you’re asked about other settings for your project. Select the Next button every time to accept the default options.

  7. When your project is ready, you’ll see a page that looks like the image below. Click on the area in the top left labelled Project.

    IntelliJ New Project

    IntelliJ New Project

  8. Clicking on Project opens a side panel, displaying the file structure of the project you have just set up.

    IntelliJ Project Window

    IntelliJ Project Window

  9. Double-clicking on the Hello file opens it in the workspace to the right.

    IntelliJ Open File

    IntelliJ Open File

  10. To run the Hello program, click on the green arrow next to the class definition and select Run ‘Hello.main()’ from the dropdown menu.

    IntelliJ Run File

    IntelliJ Run File

    After a few seconds, you should see a new window appear with your program’s output.

    IntelliJ File Output

    IntelliJ File Output

With that, you’re ready to go!

1.6.2. Troubleshooting ClassNotFoundException

After setting uo the project, if you experience java.lang.ClassNotFoundException when you run the code, follow these steps:

  1. Select File > Close Project. If you have any other IntelliJ projects open, close them as well.

    Find the Close Project option under the File menu.

    Close Project

  2. You should see the IntelliJ startup window. Click the gear icon next to java-web-dev-exercises and select Remove from Recent Projects.

    Startup with Project

    Remove project from recently used list.

  3. From the same startup window, select File –> New –> Project from Existing Sources.

    Startup without Project

    Start project from existing sources.

  4. When prompted, select the java-web-dev-exercises folder and click Open.

  5. In the next panel, select the Create project from existing sources radio button. Click Next.

    Create project from existing sources radio button.

    Create the project from the cloned repository.

  6. Follow the steps that IntelliJ guides you through, accepting all defaults. Each time you are prompted to overwrite IntelliJ settings files, confirm that you want to do so.

  7. Eventually the project will open, and you can successfully run your code!