Chapter 1 Introduction To Java
Chapter 1 Introduction To Java
Introduction to java
1. History of Java:
In 1990, Sun Micro Systems Inc. (US) was conceived a project to develop
software for consumer electronic devices that could be controlled by a
remote. This project was called Stealth Project but later its name was
changed to Green Project.
In January 1991, Project Manager James Gosling and his team members
Patrick Naughton, Mike Sheridan, Chris Wrath, and Ed Frank met to
discuss about this project.
Gosling thought C and C++ would be used to develop the project. But the
problem he faced with them is that they were system dependent languages.
The trouble with C and C++ (and most other languages) is that they are
designed to be compiled for a specific target and could
not be used on various processors, which the electronic devices might use.
James Gosling with his team started developing a new language, which was
completely system independent. This language was initially called OAK.
Since this name was registered by some other company, later it was
changed to Java.
James Gosling and his team members were consuming a lot of coffee while
developing this language. Good quality of coffee was supplied from a place
called “Java Island’. Hence they fixed the name of the language as Java.
The symbol for Java language is cup and saucer.· Sun formally announced
Java at Sun World conference in 1995. On January 23rd 1996,
JDK1.0 version was released
and C++.
Object Oriented Programming Language: Unlike C++, Java is purely OOP.
Distributed: Java is designed for use on network; it has an extensive library
which works in agreement with TCP/IP.
Secure: Java is designed for use on Internet. Java enables the construction of
virus-free, tamper free systems.
Robust (Strong/ Powerful): Java programs will not crash because of its
exception handling and its memory management features.
Interpreted: Java programs are compiled to generate the byte code. This byte
code can be downloaded and interpreted by the interpreter. .class file will have
byte code instructions and JVM which contains an interpreter will execute the
byte code.
Portable: Java does not have implementation dependent aspects and it yields
or gives same result on any machine.
Architectural Neutral Language: Java byte code is not machine dependent, it
can run on any machine with any processor and with any OS.
High Performance: Along with interpreter there will be JIT (Just In Time)
compiler which enhances the speed of execution.
Multithreaded: Executing different parts of program simultaneously is called
multithreading. This is an essential feature to design server side programs.
Dynamic: We can develop programs in Java which dynamically change on
Internet (e.g.:Applets).
the JDK executables when our working directory is not the JDK's binary
directory.
Setting environment variables from a command prompt: If we set the
variables from a command prompt, they will only hold for that session. To set
the PATH from a command prompt:
set PATH=C:\Program Files\Java\jdk1.5.0_05\bin;%PATH%
2. Programming Structure:
Comments: Comments are description about the aim and features of the
program. Comments increase readability of a program.
Three types of comments are there in Java:
Single line comments: These comments start with //
e.g.: // this is comment line
Multi line comments: These comments start with /* and end with */
e.g.: /* this is comment line*/
Java documentation comments: These comments start with /** and
end with */
These comments are useful to create a HTML file called API (application
programming Interface) document. This file contains description of all the
features of software.
Structure of the Java Program:
As all other programming languages, Java also has a structure.
The first line of the C/C++ program contains include statement. For
example, <stdio.h> is the header file that contains functions, like printf (),
scanf () etc. So if we want to use any of these functions, we should include
this header file in C/ C++ program.
Float Data Types: These data types handle floating point numbers
Character Data Type: This data type represents a single character. char
data type in java uses two bytes of memory also called Unicode system.
Unicode is a specification to include alphabets of all international
languages into the character set of java
Boolean Data Type: can handle truth values either true or false
e.g.:- boolean response = true;
Operators: An operator is a symbol that performs an operation. An
operator acts on variables called operands.
Arithmetic operators: These operators are used to perform
fundamental operations like addition, subtraction, multiplication etc