Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Lecture No.

Java Introduction

Java, an object-oriented programming language, was developed initially by James Gosling and colleagues at Sun
Microsystems. It was initially called Oak (named after the oak trees outside Gosling’s Office.

Characteristics of Java

The Java programming language is a high level language that can be characterized by all of the following:

 Simple

Java is one of the more simple languages. The language will seem very familiar to a C or C++ programming,
because Java’s syntax is similar. However, Java was fewer constructs than most traditional programming languages,
including C, C++, and Visual Basic.

 Object Oriented

Java does not have stand alone function, unlike C and C++, but only method associated with a class.
Everything (except for the built-in primitive types) is either a class, method, or an object. Extensive class library comes
with java, to interface with the host operating system, window manager, and network. It supports the following object-
oriented features: inheritance, polymorphism and encapsulation.

 Robust

The run time system performs the necessary checks to assure the integrity of the system. There are no pointers in
Java, which makes access of arbitrary addresses in memory not possible. All memory is handled behind the scenes by the
JRE (Java Runtime Environment). It has strong typing which requires variables to be declared correctly.

 Secure

Java was designed to be used in network environment that is why all security features were incorporated with the
language to prevent invasion from the outside and intrusion of unauthorized codes with malicious intents.

 High Performance

The Java platform achieves superior performance by adopting a scheme by which the interpreter can run at full
speed. This makes the users perceive that interactive application respond quickly even though they are interpreted.

 Interpreted

The Java interpreter can execute Java byte codes directly on any machine to which the interpreter and run-time
system have been ported.

 Threaded

It has a multithreading capability that allows programmers to write applications requiring concurrent execution of
many threads. This results to the high degree of interactivity for the end user. It also has built-in synchronization
mechanisms found in the Thread class.

 Dynamic

Java classes are linked only as needed.


The Java Platform

A platform is the hardware or software environment in which a program runs. The Java platform has two
components:

1. The Java Virtual Machine (JVM)


- It is the program that interprets the byte codes of a Java application into machine codes.
2. The Java Application Programming Interface (Java API)
- It is a large collection of ready-made software components to provide many useful capabilities,
such as graphical interface (GUI) widgets. It is a grouped of packages libraries of related classes
and interfaces.

The Java 2 SDK

The J2SDK (Java 2 Sun’s Development Kit), which was originally known as the JDK (Java Development Kit), is
what you use to create programs for the Java 2 Platform, Standard Edition (J2SE). it includes a set of command-lines tools
for creating Java applications and Applets. It also includes the JRE (Java Runtime Environment), which the environment
where the Java programs run, and set of standard Java libraries needed for Java programs.

The following are the Java SDK tools:

 javac - the java compiler


 java - java application launcher
 appletviewer - java applet launcher
 javadoc - java commenting tool
 jdb - java debugger
 javap - java disassembler
 jar - java archieve manager
 javah - java header file generator

Java Application and Java Applets

The following are the two kinds of java programs:

 Java Applications
o It is a Java stand alone program.
o They started in the command line.
o It has a main method where the program begins the execution.

 Java Applets
o It is a program that can be downloaded over the web.
o They are started by a web browser.
o They should be embedded in an HTML file.
o It does not have a main method.

The Java Application Programming Interface

The Java Application Programming Interface (API) consists of classes created by Sun Microsystems and stored in
library files called packages. You can use these classes and write programs without knowing the details of the API, but as
you get more advanced in your programming, you will find it necessary to learn more about details of some classes.

List of some of the common API packages:

Package Purpose
java.applet Create applets
java.awt Provides graphical components using abstract windows toolkit
java.beans Create software components
java.io Handles input and output of data
java.lang Provides core functions of the language; automatically included
java.math Handles math function, very large integers, and decimal values
java.net Provides networking
java.rmi Provides remote objects
java.security manages certificates, signatures, and other security
java.sql queries database
java.swing Provides GUI using Java Foundation Classes
java.text Manipulates text including searches
java.util Provides utilities such as dates

Comments – are not executed when the program runs. Comment lines display in coding itself and on printouts of the
source code, but they do not cause the computer to perform any given task.

Two types of comments

1. Block comment
 Begins with forward slash followed by an asterisk (/*) and ends with the symbols reversed, an asterisk
followed by a forward slash (*/)
 It is used in describing larger sections of code.

2. Line comment
 Is a comment that spans only a single line or part of a line.
 Often called as traditional comment
 It is used to described the purpose of a single command and is placed at the end of the same line as that
command
 It is begin with two forwarded slashes
 It is used when describing the intended meaning of the current line of the code.

You might also like