Working with Java

To write java code you have two options. You can either create a project, or create a single java class file. The difference between a single class and a project is if you need to write just a few classes, just create a single class file. If, however, you are working on a larger project which encompasses a number of interdependent classes, create a project.

Single Java Class File

To create a single class, open up JCreator and close all the wizards and windows that appear. Go to File -> New -> File. A File Wizard will popup.

Select the Java File icon and press next. Give your file a name (don't add .java at the end) - make sure the filename is the same as your class name. Select where you would like the file to be saved in the location text input box and hit finish.

Creating a Project

To create a project, open up JCreator and close all the wizards and windows that appear. Go to File -> New -> Project. A Project Wizard will popup.

Select the Empty Project Icon and click next. Next give a name for your project (ex: Assignment1). A folder with that name will appear in the directory which you will specify next. Location refers to where the project file itself will be stored (whenever you create a project, JCreator behind the scenes creates a special project file that contains vital information about your project). Source Path is where your source code or your java files will be stored. Output path refers to the path to which your project will write output (ex: if your project creates and writes to a file, it will be saved in the directory specified by output path). If you are confused about these, keep them all the same (ex: make all directories c:\CS 211\ProjectName). Check (if possible) Create new workspace radio button and press finish.

Working with a Project

To open an existing project, go to File -> Open Workspace and locate your project folder. Open that and doubleclick on the workspace file. To switch between projects simply follow instructions on how to open an existing one. Now go to View -> File View and you can see all the files in your current project. To add a new class go to Project -> new class, give it a name and hit finish. To add an existing class to a project, go to Project -> Add Files and add the ones you wish. Otherwise, even files that are in the same folder, but that were not added or created as above will not be part of the project.

JCreator allows you to open multiple files simultaneously tabbing them at the top as you see in the picture below. Simply click on a tab and the corresponding file will appear in front of you and be the one you are currently working in. In the picture below notice the "x" circled in top right. It will close the currently selected file. The two buttons simply shift the file tab to the right or left.

Next: Compiling and running programs ->