You are on page 1of 5

Lesson 4

History of Java – Java is a 3rd generation programming language which was


developed by James Gosling who headed a team of experts at Sun Micro System
during the year 1991. It was initially named Oak but due to copyright issue later
on was changed to Java in the year 1995.

How a Java Program runs?

Source Code – The programming code in Java that we write in our machine.
Bytecode – It is the highly optimized intermediate code which is translated by the
java compiler from source code. It is executed by the JVM which is the java
interpreter and converted into machine code.
Machine Code – The code which is directly understood by the machine.

Characteristics of Java:
 Object oriented
 Platform independent
 Robust language
 Compiled and Interpreted
 Case sensitive
(Lesson 4 Continued…)

Types of Java Program:


1. Java Application or Standalone program – It is a Java program that is
developed to run on a computer without any help of a web browser.

2. Java or Internet Applet – It is written in Java language that can be included


in a webpage in the same was as a picture or a video clip is included. They
are run with the help of a Java supported web browser.

BlueJ – BlueJ is a development environment that allows us to develop Java


programs quickly and easily. It uses a menu driven approach that allows the users
to carry out different tasks by clicking the options available on the menu bar.
Steps to run a Java program in BlueJ

1. Open BlueJ.

Start BlueJ by finding and double clicking on its icon. If you followed the
installation directions for home, it will have an icon on the desktop.

2. Create a new project.

In BlueJ's top menu bar, select Project and New.... to get the New Project
Dialog. In Look In box, find and select the CSC211 folder that you created in
Step 1. This may require you to go up/down the directory tree a few times.
Enter the name of the project (say "HelloWorld") in File name and click
on Create.
The Project Display Area to the middle right should turn white, and an icon that
looks like a piece of paper should appear.

3. Create a new class. Click on the button New Class... to obtain the Create
New Class Dialog. Enter "HelloWorld" in the Class Name textbox, and make
sure that the Class radio button is selected. Then click on the OK button.

A yellow icon with the lable HelloWorld and diagonal lines should appear.
4. Open the editor for the class. Double click on the yellow HelloWorld icon to
open the editor for that class.

5. Modify the code for the class. When you open the HelloWorld Class, you
will see some sample code for the class, including an instance variable x, a
constructor HelloWorld, and the method named sampleMethod. This code may
be interesting the first time you see it, but it is not required. Select all of the
code and delete it. Then add your code. For example, the HelloWorld program
would be:

6. Compile the class. Click on the Compile button at the top of the editor. You
should get the message "Class compiled - no syntax erors."
7. Run the application. Go back to the main BlueJ window. If you don't see it
on the desktop screen, look at the bottom of the monitor screen -- there are two
BlueJ windows. Then, right click on the yellow HelloWorld icon, and
select void main(args) to run the main method.

You will get the Method Call Dialog. Since you don't have any command line
arguments for this method, simply click on OK.

You will get the Terminal Window with the message "Hello, world!"

Test your Skills:

Q1. What was the initial name of Java? Who invented it?

Q2. Explain Bytecode.

Q3. Write any 4 features of Java.

Q4. What are the different types of Java programs?

Q5. Define BlueJ.

You might also like