California State University, Sacramento College of Engineering and Computer Science

Computer Science 10: Introduction to Programming Logic

Getting started with JGrasp

JGrasp is a free IDE (Integrated Development Environment) specifically targeted for computer science education. It's more primitive than or other IDEs, but it is the easiest IDE to learn.

JGrasp can be downloaded on your home computer. For more information, see the JGrasp website.

Using JGrasp on the lab computers

JGrasp is installed on all the ECS lab computers, as well as on the Hydra remote server cluster. To get started, do the following:

1. Search for “JGrasp” in the start menu and click it.

2. JGrasp will ask you to allow data collection and to update, probably in that order. Feel free to dismiss both dialog boxes (“Don't Allow” and “Remind me later”).

Feel free to dismiss this dialog box. 2 3. You will be presented with the following window. This is JGrasp.

The “Code Window” is where you will be editing your Java code. When you run your application, you'll be able to type input into the “Console Window” and see results.

4. BEFORE you can start editing, you have to create a new Java document for JGrasp. Click the File menu in the upper-left hand corner. Select “New” and then “Java”. The JGrasp window will change and several toolbars will appear. There are several items of interest:

This button compiles your program but does not run it. Great for testing for syntax Compile Button errors (the Java compiler will print a message if your program has one or more)

Run Button Compiles and runs your program.

Compiles and runs your program, but also enables breakpoints. These allow you Debug Button to tell the program to stop at a certain line so you can look at variable values and step through line by line. Ask me for a demo.

JGrasp has support for editing mutiple documents using a tabbed window. For whatever reason, the tabs are along the bottom of the Code Window. “[Grasp 1]” is

the name of a file that hasn't been saved yet. Once you save your file, this will

change to be the filename you specified. Document Tab

3 5. Paste or type your Java program into the Code Window, then press Control+S to save (or click File → Save). JGrasp will suggest a filename for you.

Your filename must match the “class” name in your Java program. Flowgorithm uses MyProgram by default. Java expects a class named MyProgram to be saved in a file called MyProgram.java

JGrasp automatically suggests an appropriate filename for you. Save it in whichever directory you please. Leave all the other settings at their defaults.

Now you're ready to program in Java!

4

Using JGrasp on your home computer

To use JGrasp on your home computer, you'll need to download JGrasp and the Java Development Kit.

1. Download the latest Java Development Kit (JDK) from the Oracle website. At the time of writing, the latest development kit is 8u92. Download the package appropriate for your system. If you're using a Windows machine, you're probably going to need the x64 (64-bit) .exe installer. The x86 (32-bit) installer may be necessary for some older machines or certain tablets. users should try to install openjdk through their package manager instead of using the Oracle installer.

2. Run the installer. Windows users can simply follow the wizard instructions. Mac OS X users are unfortunately on their own at the moment (I don't have a Mac to test).

3. Once you've installed the JDK on your machine, download and install JGrasp from the JGrasp website. You don't have to fill out their survey. Either version is fine.

4. Start JGrasp!