You are on page 1of 8

Lecture #1 Contents

Java and its Evolution  Java Introduction


 A Shirt History
 Java Features
 Java Editions
Instructor:  Evolution of Java Language
Khalid Raza  Comparing Java with C++ & Other OOPL
Department of Computer Science
Jamia Millia Islamia, New Delhi, India  Java Programming Environment
Email: kraza@jmi.ac.in | Home Page: www.kraza.in
 Summary

Instructor: K. Raza

A Brief History
Introduction
 Java is not only a programming language. Java is  Developer : Patrick Naughton
Games Gosling
a whole platform, with a huge library containing Chris Worth, Arthur Van
lots of reusable code and execution environment  Project Name:
such as security, portability cross OS and Green Project (Started in 1991)
automatic garbage collection  Purpose: To design a computer
language that could be used for
consumer devices like T.V. switchbox,
VCR, Washing Machine, etc.
Write Once, Run Anywhere  Old Name: Oak
 First Release: 1996 (Java 1.0)
 Slogal: Write Once, Run Anywhere
 Hotjava: A web-browser developed
using Java

Instructor: K. Raza Instructor: K. Raza


The Java White Paper Buzzwords
(Features): Total=11 Java Editions
 Simple  J2SE (Java 2 Standard Edition)
 Object-oriented Core Java, Client-side Programming
 Distributed
 Robust
 Secure  J2EE (Java 2 Enterprise Edition)
 Architecture Neutral Advance Java, Server-side Programming
 Portable
 Interpreted
 J2ME (Java 2 Micro Edition)
 High Performance
Consumer Electronics Programming
 Multi-threaded
 Dynamic

Instructor: K. Raza Instructor: K. Raza

Evolution of Java Language Java is Compiled and Interpreted


Versions Year New Features No. of classes
Hardware and
& interfaces Programmer
Operating System
1.0 1996 Language itself 211
1.1 1997 Inner classes, JavaBeans, 477
JDBC, RMI Source Code Byte Code
1.2 1998 Swing, Collection 1524
Framework, JIT Text Editor Compiler Interpreter
1.3 2000 CORBA, JavaSound, JNDI 1840 .java file .class file
1.4 2002 IPV6, Java Web Start, NIO 2723
Notepad, javac java
5.0 2004 Genric Class, for-each 3270 appletviewer
loop emacs,vi
netscape
6.0 2006 JDBC 4.0, GUI & JVM
onwards improvement
Instructor: K. Raza Instructor: K. Raza
Total Platform Independence Architecture Neutral & Portable

JAVA COMPILER  Java Compiler - Java source code (file with


(translator) extension .java) to bytecode (file with
extension .class)
JAVA BYTE CODE
(same for all platforms)  Bytecode - an intermediate form, closer to
machine representation
JAVA INTERPRETER
(one for each different system)
 A interpreter (virtual machine) on any target
platform interprets the bytecode.

Windows 95 Macintosh Solaris Windows NT


Instructor: K. Raza Instructor: K. Raza

Rich Class Environment


Overlap of C, C++, and Java
 Core Classes
language
Utilities
Input/Output C++
Low-Level Networking
Abstract Graphical User Interface
C Java
 Internet Classes
TCP/IP Networking
WWW and HTML
Distributed Programs

Instructor: K. Raza Instructor: K. Raza


Java better than C++ ? Object Oriented Languages -A Comparison

 No Typedefs, Defines, or Preprocessor Feature C++ Objective Ada Java


 No Global Variables C
Encapsulation Yes Yes Yes Yes
 No Goto statements
Inheritance Yes Yes No Yes
 No Pointers
Multiple Inherit. Yes Yes No No
 No Unsafe Structures Polymorphism Yes Yes Yes Yes
 No Multiple Inheritance Binding (Early or Late) Both Both Early Late
 No Operator Overloading Concurrency Poor Poor Difficult Yes
 No Fragile Data Types Garbage Collection No Yes No Yes
Genericity Yes No Yes Limited
Class Libraries Yes Yes Limited Yes

Instructor: K. Raza Instructor: K. Raza

Applications versus Applets


Java Applications
 Using J2SE, we can develop two types of  Different ways to run a Java executable
Java programs: are:
 Stand-alone applications Application- A stand-alone program executed by JVM. A
program that has a main
main method
 Web applications (applets)
 Using J2EE, we can developed client- Applet- A program embedded in a web page , to be run
when the page is browsed . A program that contains no
server based applications. main method

Instructor: K. Raza Instructor: K. Raza


Java Development Kit Process of Building and Running
Java Programs
Text Editor
 javac - The Java Compiler
 java - The Java Interpreter Java Source
javadoc HTML Files
Code
 javap - To print the Java Class Description
 jdb- The Java Debugger javac

 appletviewer -Tool to run the applets


Java Class File javah Header Files
 javaprof - Java profiler
 javadoc - documentation generator
java jdb
 javah - creates C header files

Outout
Instructor: K. Raza Instructor: K. Raza

Installing & Configuring Java Installing & Configuring Contd


 Downloading  Setting Path

On Windows:
SET PATH=C:\Program Files\Java\jdk1.6.0_10\bin; %PATH%

On Unix:
set path=(/usr/local/jdk/bin: $path)

On Linux:
export path=/usr/local/jdk/bin: $path

Instructor: K. Raza Instructor: K. Raza


Installing & Configuring Contd Directory Structure
Choosing IDE: You have three choices  Jdk Name may vary, e.g. jdk6.0

bin Compiler & tools


 Use JDK and your favourite text editor.
demo Demo files
Compile and launch program in a shell.
docs Library documentation in HTML format
include Files for compiling native methods
 Use IDE such as Eclipse, NetBean, etc. jre Java Runtime Environment files
lib Library files
 Use JDK & text editor that is integrated src The library sources
with JDK, e.g. Emac, TextPad, JEdit, etc. (after expanding src.zip)

Instructor: K. Raza Instructor: K. Raza

Hello Java

Let us Try Out // hello.java: Hello Java program


class HelloJava
Building first Java Program {
public static void main(String args[])
{
System.out.println(Hello Java);
}
}

Instructor: K. Raza
Program Processing Simple Java Applet

 Compilation //HelloWorld.java
# javac hello.java import java.applet.Applet;
results in HelloInternet.class import java.awt.*;
 Execution
# java HelloJava
public class HelloWorld extends Applet {
Hello Java
public void paint(Graphics g) {
#
g.drawString (Hello World !,25, 25);

}
}

Instructor: K. Raza Instructor: K. Raza

Calling an Applet
Applet Execution
<HTML>
<TITLE>HELLO WORLD APPLET</TITLE>
<HEAD>THE HELLO WORLD APPLET</HEAD>
<APPLET CODE=HelloWorld.class width=500 height=500>
</APPLET>
</HTML>

Using AppletViewer
Using Browser

Instructor: K. Raza Instructor: K. Raza


Summary Recommended Books for J2SE
 Java has emerged as a general purpose
OO language.
 It supports both stand alone and Internet
Applications.
 Provides an excellent set of Tools for
Application Development.

Instructor: K. Raza Instructor: K. Raza

Assignments Whats Next


 Try to write one stand-alone and one  Fundamental Programming Structures
applet program  Data Types
 Variables
 Operators
 Strings
 Input and Outputs
 Control Flow
 Arrays

Instructor: K. Raza Instructor: K. Raza

You might also like