Presentation is loading. Please wait.

Presentation is loading. Please wait.

Running a Java Program using Blue Jay.

Similar presentations


Presentation on theme: "Running a Java Program using Blue Jay."— Presentation transcript:

1 Running a Java Program using Blue Jay

2 Start Blue Jay by double clicking on the short cut that appears on your desktop
You should see a large window as shown in the following picture

3 Under project select “New project”.

4 Under your desktop directory, “ …. /desktop/”, type project1 (“…
Under your desktop directory, “ …./desktop/”, type project1 (“…./desktop/project1”). This should create a folder called project1 under your desktop directory

5 Now Click the New Class … button
Write the Class name to be: SimpleOperationTest and click OK Note that there should not be any space between the name you choose. So SimpleOperationTest is all one word. This shows the SimpleOperationTest class in the window as follows. Note that the strips mean that the class has not been compiled yet

6 Now open the SimpleOperationTest by double clicking on it
Now open the SimpleOperationTest by double clicking on it. This opens an editor window where you can write and modify your java code. Note that Blue Jay generates some default code for your SimpleOperationTest class All of the blue code are comments. As we will learn later in the course, comments are non-executable code and programmers add them in order to document their code

7 Any program that you write for your assignments, you need to put the due date of the assignment and your name in there. This indicates that this program is being developed by you. You can delete the version number section. It is not required for this course Also make sure that any program that you develop, you write the description of the program there. This helps you to understand your code if you refer to it later Now to do your first exercise, type the code that is shown in the next slide The java code is case sensitive. Do not miss quotations, “;”, “,” or anything else that is there.

8

9 Compile the java program
The reason we need to compile a program is to make sure that syntactically the program is correct and contains no error. So to compile the code, click the compile button

10 If you have typed everything correctly, you will see “Class compiled – no syntax errors” on the status window at the bottom. Syntax error is reported if you make a mistake. Usually, the compiler is good in reporting your error. However, sometimes it may become a bit challenging to find your syntax error.

11 Note: Note that some of you may like to type this in a text file and then copy and paste it in the Blue Jay editor. In some cases the double quotation character (“) at the beginning and the end of the System.out.println statements may not be the same as the double quotation character of Blue jay editor. So, you may need to remove the quotations and re-type them so the Blue jay compiler does not complain.

12 If you make a mistake, (example: missing a semi colon (;) or a bracket or a typo), you can always click on the “?” button in the status window to get more help for your syntax errors. Every time you correct an error or a set of errors, you need to recompile the program. You need to fix all your errors until your program compiles with no error and then you can run your program.

13 Executing (running) your program:
Execution starts from one of you constructors. In this example, we only created one constructor but you can create several constructors in a class as long as their input parameters are different from each other To run the program, right click on the SimpleOperationTest class and select new SimpleOperationTest

14 The system creates an object for you and gives it a default name: in this case it is called simpleOp1 Give 10 to the value of a and 20 to the value of b and press OK

15 A new object is created. The name of the object is called simpleOp1, and the value of x and y (the are known as a and b in the parameters) are set to 10 and 20 and the sum is 30 Press ok and you see the result appears in a terminal window. After seeing the result, it is better to save it

16 Under the options in the dialog box, select “save to file …” to save the results in a file and call it simpleOp1Result.txt

17 Note that an object called simpleOp1 is created at the status bar

18 Now run the program again by right clicking on the SimpleOperationTest class
Again, choose new SimpleOperationTest to run the constructor and create a new SimpleOperationTest object The system creates another object and gives it a different name like simpleOp2 Enter 5 for a and 10 for b to be assigned to x and y in the program, and click OK

19 The new object is shown on the bottom of the window and the result is shown in the dialog box

20 Sometime, when you execute a new object, the result of the previous object is also shown in the dialog box. It is a better idea to clear the output screen and then run the object again. This way you will only see the result of that specific object on the screen To clear the output screen, under option, select “clear” Therefore, when the output box pops up, under option select “clear” first and then re-execute the object. When the result is shown, save it and put it in the assignment folder that you need to hand to the instructor on the due date.

21 After saving the results, You can destroy the objects (not the class) if you want. In order to do that, right click on the object and select “remove” After you are done with the work, close the project. Do not delete the project folder that are related to your assignment. Keep them up as back up. You can delete them at the end of the course.


Download ppt "Running a Java Program using Blue Jay."

Similar presentations


Ads by Google