This short tutorial provides directions for setting up and configuring the jGrasp programming environment on the workstations in the CSL. You will create a simple C program.

The very first thing we have to do is to figure out how to start up the programming environment and setup the correct options and preferences. This part of the lab is somewhat tedious but perhaps somewhat satisfying in an i-got-my-vcr-programmed-correctly kind of way.

Configuring jGRASP

The software development environment described here is called jGrasp. jGrasp is an Integrated Development Environment (IDE) that "integrates" a text editor, compiler, and related tools in one software application.  jGrasp was developed especially for students so it is easier to learn than industrial-strength IDE's such as Eclipse.  It is installed on all the workstations in the CSL. To launch jGRASP, open a Terminal (Applications ,> System Tools -> Terminal) and type: jgrasp

You may see a warning messages about "character encoding" and "mouse interval" which you can ignore.

Next the main window appears:

main screen

Most likely you have not used jGRASP before, so you need to configure it with the appropriate options for the way we intend to use it.  This is a one-time-only chore required the first time you use jGRASP. Choose the "Settings -> Compiler Settings -> Workspace" menu.

settings menu

The settings dialog should appear:

settings dialog

We want to set default options so jGRASP know we are creating C programs (and not some other language). Therefore, choose "C" from the drop-down "Language" menu. Next, click on the "Flags / Args / Main" tab just below the drop-down menu.

We want to set the same options in the "C/L", "Compile", and "Check" fields. In each of these, click the checkbox to the right of the text field (to enable the text field) and then enter the following text, exactly as it appears here:

-Wall -ansi -pedantic

The capitalization is important. To summarize briefly: the hyphens are a traditional UNIX syntax for "with the following option." The first one is short for "warnings: all", the second one for "use the ansi standard," and the third one for "please be pedantic."

c settings

After entering this text in all three of the boxes, click "OK."  Now that you have set these options you should not have to alter them again. 

Creating a program

At this point, you can create a simple program. From the File menu, choose "New -> C".

At this point jGRASP should open a new blank text window with "jGRASP CSD (C)" in the title bar.  Now you can type a program into this text window.

You may copy-and-paste the text in the box below into the jGRASP editor window.

#include <stdio.h>

/* Print a simple message to the screen. */
int main(void)
   printf("Greetings, Earthling.\n");
   return 0;

Now, save your work by clicking on the save icon.Save button  In the Save File Dialog which appears, provide a name for the file.  Let's use the name "greetings.c"  (All C programs should use the ".c" extension.)  Notice that the title bar now shows the filename, greetings.c.

The next step is to ask jGRASP to compile the source program. Click the Compile-and-Link button Compile-and-Link Buttonon the toolbar.

If you are a speed typist and prefer to avoid the mouse, you may
Since our program is very small, the compilation occurs almost immediately.  Look at the  "Compile Messages" box in the window at the bottom of the screen for a message indicating either success or failure. In particular, failure is indicated by an error message in green. Success is indicated by the lack of such a message.

Here's what a compiler warning looks like:


This warning message is telling you that jGRASP expects the last line of the file to be an empty line.  That is, there must be a empty line following the last line of the program.  Once you have corrected the error in the editor window,  compile-and-link the program again. Compile-and-Link Button

Once the program compiles with no warnings or errors, you will see a new file named "a.exe" appear in the Browse window on the left side of the screen.   Your program is now ready to execute!

Click on the run-application-for-current-file button, Execute button identified by a red person running.  A new window will appear with the message "---Hit any key to start".  Press the space bar (for example) and the output produced by the program will appear. We expect the message "Greetings, Earthling."  Press the space bar again to close the output window.

Congratulations, you've succeeded with your first C program!

At this point, one gigantic warning; it is VERY IMPORTANT to Compile and Link your program Compile-and-Link Button EVERY TIME before you execute itExecute button. If you fail to do this, then the program you're running does not reflect the changes you made to the source files since the last time you compiled it. 

It is very, very easy to spend half an hour trying to fix a problem with a program only to discover that you've been forgetting to click the compile-and-link button. To illustrate this lesson, delete the word "main" in the editor window, and click run button. Hey, the program still works! Now click the compile-and-link button, followed by the run button. Oh dear, the program is broken. Now retype "main" and click the run button. The program still doesn't work, even though the source file is correct. Hit yourself on the forehead, click the compile-and-link button and now the run button, and now it works again.

At this point, you are finished with the introductory section; you now know how to create a project, add a file to it, enter a program in that source file, and run it.

How to add a quick launch icon to your desktop.

If you would like to install jGRASP on your home computer you can find free downloads and installation instructions at the official web site: