Definition
Welcome to CMSI 2120! This page has setup instructions for the various technologies that we will need for the course.
Toolkit
Setup of the following is recommended by lecture L1-2 at the latest, and is mandated by lecture L2-2.
Remark
We will complete tutorials with how to use each of the following in-class and through assignments, but having them downloaded in advance will make the most out of your time in class.
Essentials
-
Download Java:
-
Get the latest LTS JDK from Adoptium Temurin (click here) — no account signup required, and the installer wires up your system paths for you.
-
Run the install executable (.msi for Windows, .pkg for Macs) and follow the instructions on your screen.
Debug
On Windows, make sure the installer’s optional features for adding Java to your PATH and setting JAVA_HOME are enabled.
These are what let you run
javacfrom a terminal, which we do in our very first lecture. -
Open either Terminal (Mac/Linux: CMD+Spacebar then search for Terminal) or Command Line (Windows: WINDOWS+R, then type
cmd, and enter). -
To test that the installation has succeeded, run the following commands (type these in the terminal one at a time then hit enter):
java -version javacIf you see no error messages from the above, you’re all set!
Careful
You need this system-wide install even though IntelliJ can fetch a JDK of its own (see the troubleshooting note further down).
We compile and run by hand at the terminal before we ever open the IDE, and only a system-wide JDK puts
javaandjavacon your PATH.
-
-
Setup Git & GitHub:
-
If you haven’t already, sign up for GitHub here
-
Debug
Note that Git has deprecated password authentication and requires you to authenticate using either ssh keys or auth tokens!
Even if you used GitHub in the past, you will need to configure a new authentication method such as here.
-
Download the
gitterminal tools here.Debug
If you are using a Windows computer, make sure to install Git Bash as part of the installation process in the above — you’ll use this instead of the basic command line for your terminal, as it just tends to work better for our objectives.
-
Open a new terminal/git bash window and type
gitand enter — if you see a bunch of options pop up, you’re good to go!
-
-
Download a plain text editor; good suggestions:
Debug
Warning: You should NOT use Microsoft Word or other document processing software for your development, it will cause more trouble than good.
- Sublime Text (my favorite for Mac)
- Notepad++ (my favorite for Windows)
- Atom
- Vim (warning: steep learning curve, but my favorite for terminal)
- Emacs (warning: steep learning curve)
Highly Recommended
Definition
An Integrated Development Environment (IDE) is a program that bundles many helpers for software development, including: language-specific text editors, compiler warnings, code suggestions, debuggers, unit-test integration, and much more!
Debug
Warning: IDEs can be intimidating at the start, but you’ll grow to love them as you gain comfort — they’re used all the time in industry, so it’s good to get some experience with one now!
For this course, we will use IntelliJ IDEA, JetBrains’ Java IDE, and it is what I will use for every in-class demonstration.
- Download the Community Edition — free, and everything this course needs — from the IntelliJ IDEA download page.
- As a student you may also claim a free Ultimate license through the JetBrains Education program using your LMU email. Either edition is fine for this class.
Environment
- Highly tailored to Java development (e.g., class and package detailing, refactoring, inspections).
- Excellent code navigation, and a debugger we will lean on heavily later in the course.
Features
- JUnit support is built in — no plugin hunting or manual configuration required.
- Some learning curve, though the defaults do a great deal of the work for you.
- Opinionated about project structure, which becomes a feature once you are used to it.
Remark
I will be using IntelliJ IDEA during class to show examples and run code, and HIGHLY suggest you use it too. Following along in the same environment makes it much easier to get unstuck, and becoming familiar with an IDE is strongly recommended.
Remark
Do not worry about mastering an IDE in advance of the class — we will see examples in IntelliJ IDEA, and the concepts translate to other development environments as well.
IntelliJ IDEA Guides
Definition
Setup Tutorial: the following walks you through installing IntelliJ IDEA, creating your first Java project, and running it.
Assignment
Definition
JUnit + Debugger Tutorial: take a look at how to run tests from the editor, and how IntelliJ’s debugger plays nicely with JUnit!
Assignment
Remark
These are JetBrains’ official guides rather than course recordings, which means they stay current with each IntelliJ release. We will still walk through all of this together in class.
IntelliJ + JUnit
Definition
This section of the tutorial applies to those using
IntelliJ IDEAas their primary development environment.
Toolkit
In order to run JUnit tests in IntelliJ, it is fairly simple, but requires one extra step to ensure that the JUnit library is on the project’s classpath.
Our assignment skeletons ship with a junit.jar, so the simplest route is to point the project at it:
- Open the project, then go to
File > Project Structure...(Ctrl + Alt + Shift + S, or⌘ + ;on a Mac). - Select Modules in the left panel, then the Dependencies tab.
- Click the
+button on the right and choose JARs or Directories… - Select the
junit.jarincluded in your assignment skeleton, leave the scope asCompile, then Apply and OK.
Toolkit
IntelliJ can often do this for you: put your cursor on a red
@Testannotation ororg.junitimport, pressAlt + Enter(⌥ + ⏎on a Mac), and choose Add ‘JUnit4’ to classpath — IntelliJ will fetch the library and attach it itself.
To run your tests, click the green ▶ arrow in the gutter beside a test class or an individual test method, or right click the test file and choose
Run '...'. Results appear in the Run tool window, with failures linked back to the offending line.
Troubleshooting
Sometimes (especially if you had some issues while setting up your project and needed to redo it) IntelliJ gets confused and JUnit is not properly situated on the classpath.
If you’re getting an error related to the JUnit runner, try the following:
-
Check that the project knows where your code lives: right click the
srcfolder and chooseMark Directory as > Sources Root. If the skeleton has a separatetestfolder, mark that one asTest Sources Root. -
Check that a JDK is selected:
File > Project Structure > Project, then make sure the SDK field names the JDK you installed above.Toolkit
If that SDK dropdown is empty — or the JDK dropdown is empty when you create a new project — you can pull one straight from the IDE.
Use
Download JDK...there. Be aware this only fixes IntelliJ: it installs to a JetBrains-managed folder rather than your system PATH, so you will still need the Essentials install above beforejavacworks at the terminal. -
Re-check the dependency:
File > Project Structure > Modules > Dependencies, and confirmjunit.jaris listed with scopeCompile. -
If everything looks right but the errors persist, choose
File > Invalidate Caches...then Invalidate and Restart — this clears a stale index, which is the usual culprit.
Debug
If you cloned your assignment from GitHub Classroom, open it with
File > Open...and select the cloned folder itself (the one containingsrc), then accept the “Trust Project” prompt. Opening a parent folder or a single file is the most common reason a skeleton appears to have no code in it.