Lesson Weekend

For our first exercises, we will be using a command line tool known as a REPL, which stands for READ - EVALUATE - PRINT - LOOP. This process works as follows:

  1. You type in a line of code and hit enter. The REPL reads this code.
  2. Next, the REPL evaluates the inputted code, figuring out what it does.
  3. The REPL prints the result of running this code.
  4. The REPL then loops back to step 1, ready for you to enter more code.

Acquiring a REPL

Luckily, setting up your REPL for Java is as easy as opening www.javarepl.com. For now, we will be using this web-based REPL for all of the Java Basics section.

Installing a Command Line REPL in OSX

Alternatively, for those of you with Macs, you can easily install javarepl onto your machine using Homebrew.

To install Homebrew, follow the instructions on Homebrew's website. Make sure to pay attention to the messages it gives you to configure your computer after it installs.

Then, just type $ brew install javarepl. After it finishes, you can launch the REPL with $ javarepl.

You can enter the Java REPL by typing $ javarepl in the terminal at any time. You can exit at any point by hitting Ctrl + C.

Installing a Command Line REPL on Windows

At time of writing (Spring 2017) there is no easy to use solution to create a REPL on a windows machine, which is unfortunate. Our teachers have explored several options, but unfortunately, our best recommendation is to use the web-based REPL for Windows users.

Terminology


  • REPL: A command line tool that allows the user to enter lines of code and see the result in the terminal when executed; stands for Read-Evaluate-Print-Loop.

Overview


  • For now, we will use the web-based JavaREPL.com as our REPL.

  • Alternatively, if you have a Mac with Homebrew installed, you may install a Java REPL by running the command $ brew install javarepl.

  • Once installed, you may launch your REPL at any time with the command $ javarepl.

  • Once open, you can exit the REPL with Ctrl + C.