CSCI A201/A597

Lab Notes 5

Spring 2000


The Symantec Cafe integrated development environment (IDE).

Getting Started with Cafe

This exercise demonstrates how to use Cafe to create a simple project. We then write the source code and compile a Java application. We break the entire process down into the following five steps:
  1. Create a new project
  2. Create a source code file
  3. Add the source file to the project
  4. Build the project
  5. Run the program
This tutorial was created a year ago for A202. The screens are probably a bit outdated, but I am sure it can help you get started with the environment nonetheless. In addition, the example is using a package called BreezyGUI that was part of the textbook and CD that we used in A202 that semester. This is not too far away from using the element package, so I don't think it will present a problem to adapt it too one of this year's examples. I will try to update the screens later in the semester, if I can, and in the meanwhile please let us know if you have any trouble running Symantec.

Step 1: Create a new Cafe project

  1. Open the Cafe environment if it is closed. (You have to find the program in the hierarchy of available programs).

  2. Click on the Editing workspace tab. (It is possible that the environment will open up in this state already). The editor that comes with Symantec is one feature significantly superior to using Notepad or anything similar.

  3. Start the Project Express wizard: in the Main window, choose Project/New. The Project Express window appears. In Symantec everything revolves around the notion of a project which is a collection of files with classes that work together to implement your program's goal).

  4. In the Project Express window change the drive to a: which should be a floppy like the one you received in the lab a couple of weeks ago (containing the element and structure packages and directories).

  5. In the Project Name dialog box type Project001.prj as the name of the project. It's actually fine to give it any other name and you should be using a name that is appropriate for the project you're working with. Note also how the selected drive lists the name of your diskette (You see that the tutorial is dated because at the time we named the floppies that we distributed by the name of the course and the semester.)

  6. The element and structure folders should be listed just like the breezygui directory is listed in the picture. BreezyGUI was the package that came with the textbook that semester. You should be creating your project at the same level as the two packages ditributed or your program won't be able to use them, as explained in class.

  7. Select the Next button at the bottom of the window (next to "Finish"). The Project Express window will display "Set project type" settings. You need to specify if your project will be an applet or an application.

  8. Choose Application for the target type, as follows:

  9. The Project Window now displays the Project001.prj project. Of course your project is currently empty.

Step 2: Create a source file

So far you haven't done anything Java yet. Various IDEs may have different interfaces and/or settings or definitions. Use the documentation that comes with the one you're having. JDK, which is available for free from Sun, does not contain anything but Java. But you have to use your own editor and compile from the command line prompt (which we will always find as a useful piece of knowledge).

We create the source code for our program now. We write Java code now. What follows is Java. What we have done so far could have been Java Workshop, Visual Age for Java, Microsoft J++, JBuilder etc.

  1. Start typing your program in the Source editing window (the example here uses the program on the page 37 of the text used in A202 one year ago. Use one of the Feb03 programs instead. Replace the two import statements with the one that imports the element package). Here's the code for the second Feb03 program for your convenience.
    import element.*; 
    
    public class Feb03Commands {
        public static void main(String[] args) {
        ConsoleWindow c = new ConsoleWindow(); 
        DrawingWindow d = new DrawingWindow(); 
    
        c.out.println("Welcome to the Line Drawing program!\n"); 
        c.out.println("At the prompt type 'line', then an x and a y and\n" + 
                      "then press Enter. The initial point is (100,100)"); 
    
        d.moveTo(100, 100); 
    
        c.out.println("To stop the program please type: quit.\n"); 
    
        c.out.print("Line> "); c.out.flush(); 
    
        while (true) {
    
          String user = c.input.readString(); 
    
          if (user.equals("quit")) {
            System.exit(0); 
          } 
    
          int dX = c.input.readInt(); 
          int dY = c.input.readInt(); 
    
          d.line(dX, dY); 
    
          c.out.print("Line> "); c.out.flush(); 
    
    
        } 
      } 
    } 
    Note that you can maximize the Source editing window for your convenience. The editor is good in Cafe and I am sure you will like it. But you do have to come up with the Java code, it won't write it for you. The editor will however help you locate compilation errors quickly, ask your lab coordinator for more details.
Step 3: Add the source file to the project

Once again, the screens that follow present the a source code for a program written for A202 of the spring 1999 semester so please don't get too confused about that. Your screens will have the source code that you type, for example the Feb03Commands class.

  1. From the Source window menu (not the Main window) choose File/Save As... (You are working with the Cafe text editor now, which is a much more evolved Notepad. Again, this is not Java, it's just an environment for developing programs which knows a bit of Java syntax though).

  2. The File Save As dialog box will appear. Select the Add to Project box. Save the file in the same directory with the project, by the name (CircleArea.java, rather call it) Feb03Commands as the class. Note that BreezyGUI's directory is in the same directory with the project in the screen. That means that your element and structure directories should be at the same level as your .java file. Now press the OK button to finish saving the file.

  3. Check your results. The CircleArea.java filename (Feb03Commands in your case) appears in the project window on the right. (See the screen presented at the next step, Building the Project). This indicates that the file is now part of the project.
Step 4: Build the project

Building the project essentially means running javac and java on the source code files in your project. An IDE hides this away from you, and sometimes for the worse. But fortunately we know how to compile and run from the command line so this won't be a problem. When we will need it (in some cases when we have a certain type of run-time errors we need to be able to use the command line) we will know how to do it.

  1. From the Main window menu choose Project/Build.

  2. Check the compiler results in the Output window. (If you do not see Successful Build you may have entered something incorrectly in the source code).
Step 5: Run the project

Steps 4 and 5 can be performed together using the runner icon that is located at the top of the window. If there are no errors then the system proceeds to invoking java on the file that contains the main class. If there are errors you ill be notified and you can quickly jump to that place in the source code by clicking on the error messages in the Output window.

If you decide to compile and run in two separate steps here's how you run the program.

  1. From the Main window menu choose Project/Execute Program.

  2. If you get an error like this follow the message on the screen: right-click on the file name in the project windown and choose Mark as Main.

  3. The target file is now checked. Choose Project/Execute Program again and the program will run.

  4. Move the program's window in the middle of the screen and test your program.
Of course this part will differ from application to application.

Notice however that the DOS window will open up any time you run an application.

When you're done exit Symantec Cafe.


Last updated: February 10, 2000 by Adrian German