Using the Jcreator Integrated Development

Total Page:16

File Type:pdf, Size:1020Kb

Using the Jcreator Integrated Development

Using JCreator

Using the JCreator Integrated Development Environment (IDE) for Programming in JAVA

Exercise 1

By: Professor Thomas G. Re - Nassau Community College

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. JCreator1 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 the text of a computer program written in the Java programming language. These reserved words are normally highlighted in blue and cannot be used as an identifier2, 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

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

1 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 Microsystems TM 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 Microsystems TM. 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 process provided 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 like Figure 1.

2 Figure 1

3. Click on File then New then Project(You will have a window that looks like

Figure 2)

Figure 2 4. 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).

a. Select an Empty project

b. Click Next

3 Figure 3 c. Provide a Location, Source Path, and Output Path. This should be a folder

in your J:\ drive3. You can change the path for each text box by clicking

on the button next to each text box illustrated above.

d. Give the project a Name4 (Here we are using HelloWorld as the project

Name)

e. Be sure that Location, Source and Output Path have the same folder as the

project Name5.

f. Click Next then Next then Finish

5. In order to continue you must complete steps 1 through 3 of the Software

Development Method found in your text bookii.

6. Create the first file for your Java program.

a. Click File then New then File (You should have the window shown in

Figure 4)

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.

4 Figure 4 b. Fill in the name of the file in the Name: text box (With this example we

use MyProg as the filename).

c. Click Finish

7. Type in the source code needed for the main implementation file6 found on page 9

8. Create the second File

a. repeat steps in step 6

b. the name of the file should be Message

9. Fill in the code for the second file found on page 9 of this document.

10. Compile each file

a. Click the tab on the top of the editor field of the file to compile

b. Click Build and Compile File not project

c. Read the errors in the Output pane of the IDE

d. Fix errors and repeat step a.

e. repeat step a. with the other files in the project

11. Compile the Project -> Click Build and then Compile Project

12. Run Project -> Click Build and then Execute 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 curly braces.

5 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.

6 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”

a. State the problem clearly and zero in to the problem specifics -> output to

the user Hello World!!!!!

b. Understand what is required to solve the problem.

2. Analysis

a. Input -> None

b. Ouput -> Hello World!!! To standard out

c. Identify additional requirements -> None

d. Identify the process that transforms the inputs to outputs - > None

e. Identify the objects for the solution to the problem

Main implementation class (new class)7

Message class ( new class )

3. Design the class

a. Locate classes in existing libraries or projects -> none for this project

b. Modify existing classes if necessary -> none for this project

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

7 c. 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

Message class

Attributes8:

String -> theMessage

Methods9:

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.

4. 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

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.

8 File 1 (Main Implementation File). public class MyProg10 { public static void main(String[] args) { Message MyMessage = new Message(); MyMessage.printMessage(); } }

File 2 (Worker File).

public class Message { private String theMessage; public Message() { theMessage = “Hello World!!!!!!!”; } public void printMessage() { System.out.println(theMessage); } public String toString() { return theMessage; }

}

5. Test and verify the complete program. a. Compile each file separately to localize the errors. i. Fix the errors ii. Recompile the file and repeat if necessary. b. Compile the whole project c. Run the project

10 Class Name must be the same as the file name

9 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 7 for this and every project that you do for this course.

10 Appendix A The JCreator IDE

Package View Pane

File View Pane Edit Window

Output Pane

11 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

12 Works Cited

13 i An Introduction to Computer Science Using Java Samuel N. Kamin, M. Dennis Mickunas, Edward M. Reingold McGraw Hill 2002 page 23 ii Problem Solving with Java Second Edition Eliot B. Koffman, Ursula Wolz Addison Wesley, New York, 2002, page 21

Recommended publications