acm/jett workshop - august 4-5, 2005 1 guidelines for using bluej

27
1 ACM/JETT Workshop - August 4-5, 2005 Guidelines For Using BlueJ

Upload: allan-franklin

Post on 12-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

1 ACM/JETT Workshop - August 4-5, 2005

Guidelines For Using BlueJ

Page 2: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

2 ACM/JETT Workshop - August 4-5, 2005

Overview

1. Lecture: Using BlueJ2. Lab Exercise - Compiling and

Running a simple program with BlueJ3. Lecture - Introduction to jar files and

packages4. Lecture + Lab Exercise - Compiling

and Running the Marine Biology Simulation using BlueJ

Page 3: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

3 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ

• Installing BlueJ• Creating a new BlueJ project• Creating a class file• Editing the class file using BlueJ • Opening the class file in the interface

mode• Compiling the class file using BlueJ• Creating an instance of an object using

BlueJ

Page 4: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

4 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Installing BlueJ

• BlueJ can be downloaded from http://www.bluej.org• J2SE SDK 5.0 can be downloaded

fromhttp://java.sun.com/j2se

Installation on lap tops : In the open lab time from 6 to 10 pm

Page 5: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

5 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating a new BlueJ Project (1 of 4)

Open BlueJ from the Program Menu

Page 6: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

6 ACM/JETT Workshop - August 4-5, 2005

Using Blue J: Creating a new BlueJ Project (2 of 4)

Left click on Projectand then again left click

on New Project

Page 7: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

7 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating a new BlueJ Project (3 of 4)

Enter the project name and left click on create

Page 8: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

8 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating a new BlueJ Project (4 of 4)

A new projectis created !

Page 9: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

9 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating a class file (1 of 2)

Left click on New ClassEnter class name in the new window

Left click on Ok

Page 10: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

10 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating a class file (2 of 2)

A new class is created !

Page 11: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

11 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Editing the class file ( 1 of 2)

Right click on the class file andthen left click on Open Editor

Page 12: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

12 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Editing the class file ( 2 of 2)

Implementation : Button to the right

The file opens up !

Page 13: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

13 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Opening the class file in the interface mode

Interface : Button to the right

The fish class documentation can be seen ! The documentation cannot be edited from here !

Page 14: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

14 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Compiling the class file

Indicates an uncompiledclass

Right click on the class fileand then left click on

compile

Page 15: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

15 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating an instance of an object (1 of 3)

Indicates a compiledclass

The class file got compiled !

Right click on class fileand left click on new MyFish()

Page 16: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

16 ACM/JETT Workshop - August 4-5, 2005

Using BlueJ: Creating an instance of an object (2 of 3)

Left click on Ok

Page 17: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

17 ACM/JETT Workshop - August 4-5, 2005

The set and get methods can invoked from here

Using BlueJ: Creating an instance of an object (3 of 3)

An instanceis created !

Page 18: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

18 ACM/JETT Workshop - August 4-5, 2005

Overview

1. Lecture: Using BlueJ2. Lab Exercise - Compiling and

Running a simple program with BlueJ3. Lecture - Introduction to jar files and

packages4. Lecture + Lab Exercise - Compiling

and Running the Marine Biology Simulation using BlueJ

Page 19: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

19 ACM/JETT Workshop - August 4-5, 2005

Lab Exercise - Compiling and Running a simple program with BlueJ

1. Use the BankAccount class from Example1.html. Complete the code. Compile it. Create an instance and check if the deposit(double amount) and withdraw(double amount) and getBalance() methods work correctly – Solution is BankAccount.java

2. Use the BankAccount class from Example2.html. Complete the code. Compile it. Create an instance and check if the getRate() method works correctly. – Solution is BankAccountStatic.java

3. These programs can be tested using Driver.java

Page 20: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

20 ACM/JETT Workshop - August 4-5, 2005

Overview

1. Lecture: Using BlueJ2. Lab Exercise - Compiling and

Running a simple program with BlueJ3. Lecture - Introduction to jar files and

packages4. Lecture + Lab Exercise - Compiling

and Running the Marine Biology Simulation using BlueJ

Page 21: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

21 ACM/JETT Workshop - August 4-5, 2005

• Java calls its class libraries “PACKAGES”• Libraries typically contain many hundreds or thousands of

different classes that are useful to developers• Java uses packages to arrange library classes into groups

that belong together

Complete packages can be imported using import package-name.*

A specific class can be imported using the full name. For example

import java.util.Random

Introduction to jar files and packages Taken as is from: Sections 4.3 and 5.5 of Objects First with Java-A Practical Introduction Using Blue J –

David J. Barnes and Michael Kolling (1 of 2)

Page 22: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

22 ACM/JETT Workshop - August 4-5, 2005

Introduction to jar files and packages First 3 points taken as is from: Appendix E2 of Objects First with Java-A Practical Introduction Using Blue

J – David J. Barnes and Michael Kolling (2 of 2)

• Java applications are usually distributed as Java Archive format files (JAR files)

• A number of different class files are archived into a single file

• A JAR file can be created as an executable file

• Tutorial on jar files : http://java.sun.com/docs/books/tutorial/jar/

Page 23: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

23 ACM/JETT Workshop - August 4-5, 2005

1. Lecture: Using BlueJ2. Lab Exercise - Compiling and

Running a simple program with BlueJ

3. Lecture - Introduction to jar files and packages

4. Lecture + Lab Exercise - Compiling and Running the Marine Biology Simulation using BlueJ

Overview

Page 24: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

24 ACM/JETT Workshop - August 4-5, 2005

Compiling the Marine Biology Simualtion using

BlueJ (1 of 4)• Website reference:http://www.bluej.org/help/ap.html

CONCEPT

All the jar files should be in +libs folderThe jar files in this project are

mbsbb.jar and mbsgui.jar

Page 25: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

25 ACM/JETT Workshop - August 4-5, 2005

http://www.bluej.org/help/ap.html

Compiling the Marine Biology Simualtion using BlueJ (2 of 4) [taken as is from bluej website]

1. Delete the 'Code' folder inside the JavaMBS folder.

2. Replace it with the BlueJ_Code folder downloaded from

Page 26: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

26 ACM/JETT Workshop - August 4-5, 2005

Compiling the Marine Biology Simualtion using BlueJ (3 of 4 )

Directories in BlueJ_Code

Page 27: ACM/JETT Workshop - August 4-5, 2005 1 Guidelines For Using BlueJ

27 ACM/JETT Workshop - August 4-5, 2005

Compiling the Marine Biology Simualtion using BlueJ – (4 of 4)

Run MBSGUI from Chap1and2MBSGUI Folder

• Open project Chap1and2MBSGUI (It has been already compiled)• Right click on MBSGUI and left click on void main (String [] args)• Hit Ok on the method call• Then on the simulation screen open a file called fish.dat• Click run on the simulation screen and observe the simulation