Using JCreator

Using the JCreator Integrated Development

Environment (IDE) for Programming in JAVA

Exercise 1

By: Professor Thomas G. Re - NassauCommunity College

Prerequisites for this exercise:

  1. Read Chapter 1 of the text book
  2. Read Appendix A on page 11 and Appendix B on page 12 of this document.
  3. Read this Exercise first,before coming to classand then do the exercise.

What is an IDE?

An IDE (Integrated Development Environment) is an application used to aid a programmer in developing computer applications or programs. This application provides a means for the programmer to quickly; identify keywords and reserve words, “edit, compile and run programs with a click of a button”[i]. JCreator[1] is an example of an IDE that will become a valuable tool for the student to use to complete each of their projects for this course.

JCreator contains a text editor that highlights the reserved words in thetext of a computer program written in the Java programming language. These reserved words are normally highlighted in blue and cannot be used as an identifier[2], method name, or class name.

This IDE also provides a means for a programmer to organize their source code into a project or package. In this way each file that is created can be placed into an easily accessible package. Each file then can be opened simultaneously in one environment. Much the same way multiple documents can be opened in a word processing program. Each file can then be edited, compiled and then run as one project within this environment. This makes editing multiple files in one program much easier than environments that only allow one file to be opened at one time.

In no means is this environment the “Compiler” for your JAVA programs. JCreator uses the JAVAC compiler developed by Sun MicrosystemsTM to compile the Java source code into Java Byte code. It is just an editor that provides an easy to use editor and debugger for creating Java source code. In order to create the JAVA byte code you still need to use the Java Compiler developed by Sun MicrosystemsTM. You can download the JAVAC compiler from java.sun.com.

Using JCreator

To use JCreator the program must first be installed on the computer correctly. If using this program in the computer labs at the college, then this is assumed. Before starting a programming project, the student should finish steps 1 to 3 of the Software development processprovided on page 7 in their textbook.

  1. Click on the JCreator icon on the desk top ( IF Dialog boxes appear click next and then ok until the IDE environment window appears).
  2. You should then have a window that looks likeFigure 1.

Figure 1

  1. Click on File then Newthen Project(You will have a window that looks likeFigure 2)

Figure 2

  1. For Every project in this class you must(These steps are modified each time you create a new project with names and folders that pertain to each project).
  2. Select an Empty project
  3. Click Next

Figure 3

  1. Provide a Location, Source Path, and Output Path. This should be a folder in your J:\ drive[3]. You can change the path for each text box by clicking on the button next to each text box illustrated above.
  2. Give the project a Name[4] (Here we are using HelloWorld as the project Name)
  3. Be sure that Location, Source and Output Path have the same folder as the project Name[5].
  4. Click Next then Next then Finish
  1. In order to continue you must complete steps 1 through 3 of the Software Development Method found in your text book[ii].
  2. Create the first file for your Java program.
  3. Click File then New then File (You should have the window shown in Figure 4)

Figure 4

  1. Fill in the name of the file in the Name: text box (With this example we use MyProg as the filename).
  2. Click Finish
  1. Type in the source code needed for the main implementation file[6] found on page 9
  2. Create the second File
  3. repeat steps in step 6
  4. the name of the file should be Message
  5. Fill in the code for the second file found on page 9 of this document.
  6. Compile each file
  7. Click the tab on the top of the editor field of the file to compile
  8. Click Build and Compile Filenot project
  9. Read the errors in the Output pane of the IDE
  10. Fix errors and repeat step a.
  11. repeat step a. with the other files in the project
  12. Compile the Project -> Click Build and then Compile Project
  13. Run Project -> Click Build and then Execute Project

When you execute the program you will have a window that looks like that in Figure 5

Figure 5

Complete this exercise by completing the key word, review questions and the review exercise at the end of this document on page 10

Note and Reminder

Although you are not getting a grade for this exercise it is important to finish this exercise to gain a firm understanding of the material discussed in this document. Not completing this exercise will ensure that you WILL NOT be able to finish project one when it is assigned. You may get help from the lab staff and other students with this exercise but not on Project 1.

You must bring this and ALL exercises to class in order to participate in class discussions.

Hello World

This is an example of using the

Software Development methodii.

There are 6 Steps to the Software Development Method. You must complete all of these steps in order to finish developing a programming project. The program problem is :

Write a program that will output to the user the words Hello World!!!! To standard output.

  1. “Specify the problem requirements”
  2. State the problem clearly and zero in to the problem specifics -> output to the user Hello World!!!!!
  3. Understand what is required to solve the problem.
  4. Analysis
  5. Input -> None
  6. Ouput -> Hello World!!! To standard out
  7. Identify additional requirements -> None
  8. Identify the process that transforms the inputs to outputs - > None
  9. Identify the objects for the solution to the problem

Main implementation class (new class)[7]

Messageclass ( new class )

  1. Design the class
  2. Locate classes in existing libraries or projects -> none for this project
  3. Modify existing classes if necessary -> none for this project
  4. Design new classes (list the attributes and methods of each new class. No coding should be done at this point).

MyProg class

Attributes:

None

Methods:

Main method

Messageclass

Attributes[8]:

String -> theMessage

Methods[9]:

Default Constructor -> initialize the string Message to “Hello World!!!”

Print Method -> Prints the string Message to standard out.

toString Method -> used to print the object HeloWorld from outside of the class HelloWorld.

  1. Implement the new classes (Coding can be done at this point and each class should be in a separate file) Type the classes into the editor and save each class

File 1 (Main Implementation File).
publicclass MyProg[10]
{
publicstaticvoid main(String[] args)
{
Message MyMessage = new Message();
MyMessage.printMessage();
}
}
File 2 (Worker File).
publicclass Message
{
privateString theMessage;
public Message()
{
theMessage = “Hello World!!!!!!!”;
}
publicvoid printMessage()
{
System.out.println(theMessage);
}
publicString toString()
{
return theMessage;
}
}
  1. Test and verify the complete program.
  2. Compile each file separately to localize the errors.
  3. Fix the errors
  4. Recompile the file and repeat if necessary.
  5. Compile the whole project
  6. Run the project

Exercise 1 review

Key Words

class / attribute / method
compile / source code / machine code
JAVA byte code / constructor / standard out
standard in

Review Questions

1. List three output devices on a computer?

2. List three input devices on a computer?

3. What is an IDE?

4. At minimum, how many files should you have with your JAVA program?

5. Explain what the main implementation (driver) class does in your JAVA program?

6. Explain why it is important to compile each file separately?

Review Exercise

Write a program like the hello world program entirely on your own. Instead of printing Hello World to the screen, output your name. Be sure to use the steps in the Software development process provided on page 7for this and every project that you do for this course.

Appendix A

The JCreator IDE

Appendix B

Close up look at the different Panes

or windows of the JCreator IDE

Project View Pane in JCreator / Class View Pane in JCreator
Output Pane with a typical Error
Output Pane Without an Error

Works Cited

1

[1] The version of JCreator used in this exercise is 3.50. It is up to the student to ensure that he/she is using the correct version of the IDE

[2] An Identifier is a name given to

[3] Your J:\ drive is space provided for each student on the computer network at school. This only pertains to projects that are done at school. If you do projects at home then select a folder on you C: drive on your local computer.

[4] All programs that are written for this course are to be placed in a project and given a unique name

[5] This will create a folder in the J:\ drive with the same name as the project.

[6]A big Note: when typing the source code for your project fill in what you can at the moment (this will change as the program gets larger). For Example type in the keywords that make up the class, attributes of the class, and method headings and curlybraces.

[7] Every program should contain at least two classes. The main implementation class and the worker class or object.

[8] Attributes describe an object i.e. colour, name, age etc. Normally contains the data that describes an object

[9] Methods provide an action on an object i.e. Set, initialize data or attributes, print attributes, etc.

[10] Class Name must be the same as the file name

[i]An Introduction to Computer Science Using Java Samuel N. Kamin, M. Dennis Mickunas, EdwardM.ReingoldMcGrawHill2002 page 23

[ii]Problem Solving with Java Second Edition Eliot B. Koffman, Ursula Wolz Addison Wesley, New York, 2002, page 21