Creating an Application in JCreator

When you open JCreator, you should see the following screen. No file has either been created or loaded.

To create a new application, either click on the icon in the upper left hand corner (below File) or pull down the File menu. If you use the File menu, click on New. In either case, you will see the next window. Click on the Empty Project icon. This will allow you to create a totally new project.

Change the Location box to the disk or folder where you want your project to be. Also enter the projectís name into the Project name box.

Next create a file that will be in the project. Again go to the File menu and select New. This time you will see a window with the Files tab selected.

This time the Location box will show where the project is. Type a name into the Filename box. It should be the name of the application that you will be adding to the project. After clicking on OK, you will be ready to begin typing in your application.

Now type in the following Java application. Type your own name where it says <Name> and the current date where it says <Date>.

// Computer Science <Course Number>
// Java application written by <Name>.
// <Date>// An application with a class that provides information about a person.

public class People
{
    public static void main (String [] args)
    {
        Person girl = new Person();
        girl.displayAge ();
    } // method main
} // class People

// Class that stores information about a person's name and age.
class Person
{
    private String name;
    private int age;

    public Person ()
    {
        name = "Alice";
        age = 7;
    } // constructor

    public void displayAge ()
    {
        System.out.println (name + "'s age is " + age);
    } // method displayAge
} // class Person

When finished, you should see the following screen.
 

Save your file by selecting Save from the File menu or by clicking on the Save file icon. You are now ready to compile your project. The application must be translated into Java bytecode before it can be executed. From the Build menu, select Compile Project, or click on the Compile Project icon on the toolbar. (You can find it by placing your mouse pointer over each one of the icons.)

If your program compiled without any syntax errors, the window at the bottom will say Process Completed. If so, you are ready to Run your program. On the Build menu, choose Execute Project or click on the Execute Project icon. In either case you should see the next window.

If so, you can print out a copy of your program using the Print command on the File menu. Write your name on the sheet and hand it in to your instructor with your (labeled) disk.

If there were syntax (grammar) errors in your program, they will have to be fixed before you can run the application. Suppose, for example, that you mispelled Person as Prson in line 8. Now when you compile your project, the Java compiler will flag that error. If you click on the line number in the error message, JCreator will take you to the line in question, as shown below.

Here it says that it cannot resolve the symbol, meaning the word Prson. Correct your error and recompile. If there are more errors, they will also be flagged. Otherwise you will be able to run your program.

If you cannot figure out what the error is, you can check the Java documentation. This might provide some insight into the problem. You can access help by clicking on the first question mark icon. When you do, you get the next window. From this you can get information about Java syntax and classes.

You leave JCreator by either selecting Exit from the File menu or clicking on the Exit icon.