SlideShare a Scribd company logo
www.corewebprogramming.com
Java is Web-Enabled?
• Myth: Java is only for the Web
– Java “applets” run in Web pages
– Java “applications” run stand-alone
– Current usage (roughly)
• Client (applet): 5%
• Desktop (application): 45%
• Server (servlets/JSP/EJB): 50%
www.corewebprogramming.com
Java is Safe?
• Truth: Restrictions on permissible
operations can be enforced
– No “raw” memory manipulation (directly or indirectly).
• Thus, it is easy to identify prohibited operations.
– Applets, by default, prohibited from:
• Reading from the local disk
• Writing to the local disk
• Executing local programs
• Opening network connections other than to HTTP
server
• Discovering private info about user (username,
directories, OS patch level, applications installed,
etc.).
www.corewebprogramming.com
Java
Source Code
Java Bytecode
Compiler
(javac)
Java Bytecode
Execution
JIT Compiler
or Interpreter
Compile Time Run Time
Java is Cross-Platform?
• Truth: Java programs can compile to
machine-independent bytecode
• Truth: All major operating systems have
Java runtime environments
– Most bundle it (Solaris, MacOS, Windows 2000, OS/2)
www.corewebprogramming.com
Java is Cross-Platform?
• Myth: Safety and machine independence
can be achieved with no performance
penalty
– Current systems are about 20% slower than C++
– Upcoming releases claim to lower or eliminate that gap
– Expect the gap to stay at 10% or more
• Myth: Java is interpreted
– Early releases were interpreted
– Many major “Just in Time” (JIT) compilers
– HotSpot and “native” compilers even faster (IBM,
Symantec, TowerJ, etc.)
www.corewebprogramming.com
•Truth: Java has a portable graphics library
“Native look & feel” -- Java 1.1 UI controls adapt to OS
•Myth: The graphics library has everything
most applications need.
AWT (Java 1.0 and 1.1) was weak. JFC/Swing (Java 2)
much more complete and powerful.
Java is Cross-Platform?
www.corewebprogramming.com
Java is Cross-Platform?
• Myth: Write Once Run Anywhere
– Cross-platform code can be achieved, but you must test
on all platforms you will deliver on.
• Java applications can execute local code
• The graphics library behaves slightly differently on
different platforms
• The behavior of the thread scheduler is only loosely
defined
• Myth: Java will kill Microsoft
– There is also no longer immediate danger of the reverse
(Microsoft killing Java)
– Microsoft wavered between trying to fight Java and
joining it and making money by dominating the market.
With .NET, they are back to fighting it again.
www.corewebprogramming.com
Java is Simple?
• Truth: Java greatly simplifies several
language features
– Java has automatic memory management
• Does Windows and takes out the garbage
• No dangling pointers. No memory leaks.
• A problem for real-time programs
– Java simplifies pointer handling
• No explicit reference/dereference operations
• Everything is a pointer (like Lisp)
– No makefiles
– No header files
– C++ syntax streamlined
www.corewebprogramming.com
Java is Powerful?
• Truth: Java has a rich set of standard
libraries
– Networking
– Threads (lightweight processes)
– Distributed objects
– Database access
– Graphics: GUI controls and drawing
– Data structure library
– Arbitrary precision integral and fixed-point arithmetic
– Digital signatures
– Serialization (transmitting/reassembling data structures)
– File and stream compression
www.corewebprogramming.com
Java is Powerful?
• Myth: Java will increase programmer
productivity for all applications by XXX%.
• Myth: Java will kill C++
• Myth: All software should be written in Java
– Unix utilities: C
– Small/medium Windows-only programs: Visual Basic
– String parsing: Perl
– High-performance, single-platform OO systems: C++
– Air traffic control, aircraft flight software: Ada
– Knowledge-based systems: Lisp/CLOS
www.corewebprogramming.com
Key Java Packages
and Protocols
• Core Technologies
– JDBC
– RMI
– Jini (Device Networking)
– JavaBeans
– Swing
– Java 2D
• Standard Extensions
– Servlets and JavaServer Pages (JSP)
– Enterprise Java Beans
– Java 3D
www.corewebprogramming.com
Java Packages and Protocols:
JDBC (Java DataBase Connectivity)
• Standardizes mechanism for making
connection to database server
– Requires server-specific driver on client. No change to
server.
• Standardizes mechanism for sending
queries
– Either regular or parameterized queries (stored
procedures)
• Standardizes data structure of query result
– Assumes relational data, so data structure is a table
• Does not standardize SQL syntax
– Queries are simply strings
– Server extensions and enhancements supported
www.corewebprogramming.com
Java Packages and Protocols:
Remote Method Invocation (RMI)
• Built-in Distributed Object Protocol
– RMI lets a developer access a Java object and manipulate
it in the normal manner. Behind the scenes, each function
call really goes over the network to a remote object.
– Arbitrary Java data structures can be sent over the
network with little or no special packaging, due to Java’s
“serialization” mechanism
– Similar to a simplified CORBA, but restricted to
Java-to-Java communication
• Jini
– RMI-based protocol for self-documenting services.
– Allows real “plug and play” devices -- no separate drivers
– Jury is out on eventual success. Security and industry
adoption are open questions.
www.corewebprogramming.com
Java Packages and Protocols:
JavaBeans
• JavaBeans is to Java as ActiveX is to
Visual C++.
– Lets you package a Java program
as a software “component”
– Visual tools can modify/manipulate
it without knowing anything about
it in advance
• For example, you can drop a Bean into
Visual Café, IBM VisualAge for Java,
Inprise (Borland) JBuilder, Sybase PowerJ,
Metrowerks CodeWarrior, Sun JavaWorkshop, etc.,
and it is automatically available from their tool palette
for drag-and-drop development
– Better security and portability than ActiveX
– More ActiveX components available
www.corewebprogramming.com
Java Packages and Protocols:
Swing
• Standard GUI-control (widget) library in Java
2
• Many more built-in controls
• Much more flexible and customizable
• Includes many small features aimed at
commercial applications
– Tooltips, tabbed panes, on-line
help, HTML support, dockable
toolbars, multi-document
interface, etc.
• Look and feel can be
changed at run time
www.corewebprogramming.com
Java Packages and Protocols:
Servlets and JavaServer Pages (JSP)
• Servlets: Java’s answer to CGI
– Efficient: thread, not process, per request
– Convenient: HTTP headers, cookies, etc.
– Powerful: persistence, session tracking, etc.
– Secure: no buffer overflows or shell escapes
• Supported by virtually all Web servers:
– Native support: Netscape/iPlanet, IBM WebSphere, Oracle
8i/9i and Oracle Application Server, BEA WebLogic,
Silverstream, Sapphire/Web, etc.
– Via add-on engine: Apache, Microsoft IIS and Personal
WebServer, Netscape FastTrack, O’Reilly WebSite, StarNine
WebSTAR for MacOS, etc.
• JavaServer Pages (JSP)
– Convenient and efficient way to combine servlets and
HTML. Portable alternative to ASP & ColdFusion.
www.corewebprogramming.com
Java Packages and Protocols:
Enterprise JavaBeans (EJB)
• EJBs are to server components
what regular JavaBeans are to
application components
• Standardizes access to
services like load balancing,
persistence, failover, etc.
• Builds on JavaBeans, CORBA, and RMI
“under the hood”
• Potentially accessible via non-Java
programs
• Application Servers Supporting EJB
– BEA WebLogic, IBM WebSphere, Netscape, Oracle,
Progress SW Apptivity, NetDynamics, Sybase, Bluestone
Saphire/Web etc.
www.corewebprogramming.com
Basic Hello World Application
• “Application” is Java lingo for a stand-alone
Java program
– Note that the class name and the filename must match
– A file can contain multiple classes, but only one can be
declared public, and that one’s name must match the
filename
• File HelloWorld.java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world.");
}
}
www.corewebprogramming.com
Basic Hello World Application
(Continued)
• Compiling:
javac HelloWorld.java
• Running:
java HelloWorld
• Output:
Hello, world.
www.corewebprogramming.com
Command Line Arguments
• File ShowArgs.java:
public class ShowArgs {
public static void main(String[] args) {
for(int i=0; i<args.length; i++) {
System.out.println("Arg " + i +
" is " + args[i]);
}
}
}
www.corewebprogramming.com
Command Line Arguments,
Results
• Compiling and Running:
> javac ShowArgs.java
> java ShowArgs fee fie foe fum
Arg 0 is fee
Arg 1 is fie
Arg 2 is foe
Arg 3 is fum
www.corewebprogramming.com
Basic Hello WWW Applet
• File HelloWWW.java:
import java.applet.Applet;
import java.awt.*;
public class HelloWWW extends Applet {
public void init() {
setBackground(Color.gray);
setForeground(Color.white);
setFont(new Font("SansSerif", Font.BOLD, 30));
}
public void paint(Graphics g) {
g.drawString("Hello, World Wide Web.", 5, 35);
//5=left, 35=bottom
}
}
www.corewebprogramming.com
Basic Hello WWW Applet
(Continued)
• File HelloWWW.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<TITLE>HelloWWW: Simple Applet Test.</TITLE>
</HEAD>
<BODY>
<H1>HelloWWW: Simple Applet Test.</H1>
<APPLET CODE="HelloWWW.class" WIDTH=400 HEIGHT=40>
<B>Error! You must use a Java enabled browser.</B>
</APPLET>
</BODY>
</HTML>
www.corewebprogramming.com
Basic Hello WWW Applet
(Continued)
• Compiling:
javac HelloWWW.java
• Running:
Load HelloWWW.html in a Java-enabled browser
www.corewebprogramming.com
Customizing Applets with
PARAM
import java.applet.Applet;
import java.awt.*;
public class Message extends Applet {
private int fontSize;
private String message;
public void init() {
setBackground(Color.black);
setForeground(Color.white);
fontSize = getSize().height - 10;
setFont(new Font("SansSerif", Font.BOLD, fontSize));
// Read heading message from PARAM entry in HTML.
message = getParameter("MESSAGE");
}
public void paint(Graphics g) {
if (message != null)
g.drawString(message, 5, fontSize+5);
}
}
www.corewebprogramming.com
Customizing Applets with
PARAM, cont.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>The Message Applet</TITLE>
</HEAD>
<BODY BGCOLOR="WHITE">
<H1>The <CODE>Message</CODE> Applet</H1>
<P>
<APPLET CODE="Message.class" WIDTH=325 HEIGHT=25>
<PARAM NAME="MESSAGE" VALUE="Tiny">
<B>Sorry, these examples require Java</B>
</APPLET>
<P>
<APPLET CODE="Message.class" WIDTH=325 HEIGHT=50>
<PARAM NAME="MESSAGE" VALUE="Small">
<B>Sorry, these examples require Java</B>
</APPLET>
...
</BODY>
</HTML>
www.corewebprogramming.com
Customizing Applets with
PARAM, Result
www.corewebprogramming.com
Summary
• Java is a complete language, supporting
both standalone applications and Web
development
• Java is compiled to bytecode and can be
run on any platform that supports a Java
Virtual Machine
• Java 2 Platform is available in a Standard
Edition, Enterprise Edition, or Micro Edition
• Compiling: use “javac”
• Executing standalone programs: use “java”
• Executing applets: load HTML file in
browser
Ad

Recommended

Java
Java
QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN
 
Preparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
Play Framework and Activator
Play Framework and Activator
Kevin Webber
 
DevNexus 2019: Migrating to Java 11
DevNexus 2019: Migrating to Java 11
DaliaAboSheasha
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
Ryan Cuprak
 
Java 8 in Anger (JavaOne)
Java 8 in Anger (JavaOne)
Trisha Gee
 
Developing in the Cloud
Developing in the Cloud
Ryan Cuprak
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
Ryan Cuprak
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak
 
Scala in the Wild
Scala in the Wild
Tomer Gabel
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
An Introduction to Play 2 Framework
An Introduction to Play 2 Framework
PT.JUG
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
History of Java 1/2
History of Java 1/2
Eberhard Wolff
 
OSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and Android
mfrancis
 
Migrating to Java 11
Migrating to Java 11
Arto Santala
 
Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?
Dev_Events
 
Apache Cordova 4.x
Apache Cordova 4.x
Ivano Malavolta
 
itft-Java evolution
itft-Java evolution
Atul Sehdev
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7
Roberto Cortez
 
Play framework productivity formula
Play framework productivity formula
Sorin Chiprian
 
Eureka Moment UKLUG
Eureka Moment UKLUG
Paul Withers
 
From Java to Ruby...and Back
From Java to Ruby...and Back
Anil Hemrajani
 
Java Web Start - How Zhara POS Works
Java Web Start - How Zhara POS Works
Yohan Liyanage
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
Coimbra JUG
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Duckademy IT courses
 
Java tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
9 cm604.1
9 cm604.1
myrajendra
 

More Related Content

What's hot (19)

[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak
 
Scala in the Wild
Scala in the Wild
Tomer Gabel
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
An Introduction to Play 2 Framework
An Introduction to Play 2 Framework
PT.JUG
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
History of Java 1/2
History of Java 1/2
Eberhard Wolff
 
OSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and Android
mfrancis
 
Migrating to Java 11
Migrating to Java 11
Arto Santala
 
Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?
Dev_Events
 
Apache Cordova 4.x
Apache Cordova 4.x
Ivano Malavolta
 
itft-Java evolution
itft-Java evolution
Atul Sehdev
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7
Roberto Cortez
 
Play framework productivity formula
Play framework productivity formula
Sorin Chiprian
 
Eureka Moment UKLUG
Eureka Moment UKLUG
Paul Withers
 
From Java to Ruby...and Back
From Java to Ruby...and Back
Anil Hemrajani
 
Java Web Start - How Zhara POS Works
Java Web Start - How Zhara POS Works
Yohan Liyanage
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
Coimbra JUG
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration
Kazuchika Sekiya
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak
 
Scala in the Wild
Scala in the Wild
Tomer Gabel
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
An Introduction to Play 2 Framework
An Introduction to Play 2 Framework
PT.JUG
 
Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
Saeed Zarinfam
 
OSGi Community Event 2010 - OSGi and Android
OSGi Community Event 2010 - OSGi and Android
mfrancis
 
Migrating to Java 11
Migrating to Java 11
Arto Santala
 
Liberty: The Right Fit for Micro Profile?
Liberty: The Right Fit for Micro Profile?
Dev_Events
 
itft-Java evolution
itft-Java evolution
Atul Sehdev
 
Server Side JavaScript on the Java Platform - David Delabassee
Server Side JavaScript on the Java Platform - David Delabassee
JAXLondon2014
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7
Roberto Cortez
 
Play framework productivity formula
Play framework productivity formula
Sorin Chiprian
 
Eureka Moment UKLUG
Eureka Moment UKLUG
Paul Withers
 
From Java to Ruby...and Back
From Java to Ruby...and Back
Anil Hemrajani
 
Java Web Start - How Zhara POS Works
Java Web Start - How Zhara POS Works
Yohan Liyanage
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
Coimbra JUG
 

Viewers also liked (20)

Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Duckademy IT courses
 
Java tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
9 cm604.1
9 cm604.1
myrajendra
 
SEM5- NPD -Chapter2 development processes
SEM5- NPD -Chapter2 development processes
BTEC UTeM
 
Introduction To Java.
Introduction To Java.
Tushar Chauhan
 
Speedup Your Java Apps with Hardware Counters
Speedup Your Java Apps with Hardware Counters
C4Media
 
Presentation on Core java
Presentation on Core java
mahir jain
 
Java Presentation
Java Presentation
aitrichtech
 
Core java
Core java
Sun Technlogies
 
Training ppt bsnl
Training ppt bsnl
manish katara
 
Core java concepts
Core java concepts
Ram132
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01
Adil Kakakhel
 
Java programming course for beginners
Java programming course for beginners
Eduonix Learning Solutions
 
New final bsnl training report
New final bsnl training report
manish katara
 
Java Tutorial
Java Tutorial
Vijay A Raj
 
Client Server Architecture
Client Server Architecture
suks_87
 
BSNL Industrial Training ppt 2014.
BSNL Industrial Training ppt 2014.
Shubham Singh
 
bsnl project report
bsnl project report
Tara Saini
 
Oops ppt
Oops ppt
abhayjuneja
 
Client server architecture
Client server architecture
Whitireia New Zealand
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Duckademy IT courses
 
SEM5- NPD -Chapter2 development processes
SEM5- NPD -Chapter2 development processes
BTEC UTeM
 
Speedup Your Java Apps with Hardware Counters
Speedup Your Java Apps with Hardware Counters
C4Media
 
Presentation on Core java
Presentation on Core java
mahir jain
 
Java Presentation
Java Presentation
aitrichtech
 
Core java concepts
Core java concepts
Ram132
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01
Adil Kakakhel
 
New final bsnl training report
New final bsnl training report
manish katara
 
Client Server Architecture
Client Server Architecture
suks_87
 
BSNL Industrial Training ppt 2014.
BSNL Industrial Training ppt 2014.
Shubham Singh
 
bsnl project report
bsnl project report
Tara Saini
 
Ad

Similar to 01 java intro (20)

1java Introduction
1java Introduction
Adil Jafri
 
Advance java prasentation
Advance java prasentation
dhananajay95
 
Java2 platform
Java2 platform
Sajan Sahu
 
How to use Java in Web Application Development?
How to use Java in Web Application Development?
Inexture Solutions
 
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
abile technologies
 
Java overview 20131022
Java overview 20131022
hamidsamadi
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Software environment
Software environment
Kinnudj Amee
 
Software requirement
Software requirement
madhukarreddy007
 
PPT on JAVA
PPT on JAVA
Er Bhagat Sharma
 
Corejava ratan
Corejava ratan
Satya Johnny
 
Easy way to learn Core java full material
Easy way to learn Core java full material
Sivannarayana Chimata
 
Java language pppppt
Java language pppppt
curiosityjunction
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptx
VeerannaKotagi1
 
introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus
Unit Nexus Pvt. Ltd.
 
Object Oriented concept-JAVA-Module-1-PPT.pptx
Object Oriented concept-JAVA-Module-1-PPT.pptx
ASHWINIGOWDA46
 
00 intro to java
00 intro to java
Deia Abdullah
 
Java application-development
Java application-development
Deepika Chaudhary
 
Features of java unit 1
Features of java unit 1
RubaNagarajan
 
Java for Recruiters
Java for Recruiters
ph7 -
 
1java Introduction
1java Introduction
Adil Jafri
 
Advance java prasentation
Advance java prasentation
dhananajay95
 
Java2 platform
Java2 platform
Sajan Sahu
 
How to use Java in Web Application Development?
How to use Java in Web Application Development?
Inexture Solutions
 
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
abile technologies
 
Java overview 20131022
Java overview 20131022
hamidsamadi
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Software environment
Software environment
Kinnudj Amee
 
Easy way to learn Core java full material
Easy way to learn Core java full material
Sivannarayana Chimata
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptx
VeerannaKotagi1
 
introduction to java-final with Unit Nexus
introduction to java-final with Unit Nexus
Unit Nexus Pvt. Ltd.
 
Object Oriented concept-JAVA-Module-1-PPT.pptx
Object Oriented concept-JAVA-Module-1-PPT.pptx
ASHWINIGOWDA46
 
Java application-development
Java application-development
Deepika Chaudhary
 
Features of java unit 1
Features of java unit 1
RubaNagarajan
 
Java for Recruiters
Java for Recruiters
ph7 -
 
Ad

Recently uploaded (20)

A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
2025 Completing the Pre-SET Plan Form.pptx
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
How to use _name_search() method in Odoo 18
How to use _name_search() method in Odoo 18
Celine George
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
A Visual Introduction to the Prophet Jeremiah
A Visual Introduction to the Prophet Jeremiah
Steve Thomason
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
HistoPathology Ppt. Arshita Gupta for Diploma
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
List View Components in Odoo 18 - Odoo Slides
List View Components in Odoo 18 - Odoo Slides
Celine George
 
2025 Completing the Pre-SET Plan Form.pptx
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Photo chemistry Power Point Presentation
Photo chemistry Power Point Presentation
mprpgcwa2024
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
How to use _name_search() method in Odoo 18
How to use _name_search() method in Odoo 18
Celine George
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
English 3 Quarter 1_LEwithLAS_Week 1.pdf
English 3 Quarter 1_LEwithLAS_Week 1.pdf
DeAsisAlyanajaneH
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 

01 java intro

  • 1. www.corewebprogramming.com Java is Web-Enabled? • Myth: Java is only for the Web – Java “applets” run in Web pages – Java “applications” run stand-alone – Current usage (roughly) • Client (applet): 5% • Desktop (application): 45% • Server (servlets/JSP/EJB): 50%
  • 2. www.corewebprogramming.com Java is Safe? • Truth: Restrictions on permissible operations can be enforced – No “raw” memory manipulation (directly or indirectly). • Thus, it is easy to identify prohibited operations. – Applets, by default, prohibited from: • Reading from the local disk • Writing to the local disk • Executing local programs • Opening network connections other than to HTTP server • Discovering private info about user (username, directories, OS patch level, applications installed, etc.).
  • 3. www.corewebprogramming.com Java Source Code Java Bytecode Compiler (javac) Java Bytecode Execution JIT Compiler or Interpreter Compile Time Run Time Java is Cross-Platform? • Truth: Java programs can compile to machine-independent bytecode • Truth: All major operating systems have Java runtime environments – Most bundle it (Solaris, MacOS, Windows 2000, OS/2)
  • 4. www.corewebprogramming.com Java is Cross-Platform? • Myth: Safety and machine independence can be achieved with no performance penalty – Current systems are about 20% slower than C++ – Upcoming releases claim to lower or eliminate that gap – Expect the gap to stay at 10% or more • Myth: Java is interpreted – Early releases were interpreted – Many major “Just in Time” (JIT) compilers – HotSpot and “native” compilers even faster (IBM, Symantec, TowerJ, etc.)
  • 5. www.corewebprogramming.com •Truth: Java has a portable graphics library “Native look & feel” -- Java 1.1 UI controls adapt to OS •Myth: The graphics library has everything most applications need. AWT (Java 1.0 and 1.1) was weak. JFC/Swing (Java 2) much more complete and powerful. Java is Cross-Platform?
  • 6. www.corewebprogramming.com Java is Cross-Platform? • Myth: Write Once Run Anywhere – Cross-platform code can be achieved, but you must test on all platforms you will deliver on. • Java applications can execute local code • The graphics library behaves slightly differently on different platforms • The behavior of the thread scheduler is only loosely defined • Myth: Java will kill Microsoft – There is also no longer immediate danger of the reverse (Microsoft killing Java) – Microsoft wavered between trying to fight Java and joining it and making money by dominating the market. With .NET, they are back to fighting it again.
  • 7. www.corewebprogramming.com Java is Simple? • Truth: Java greatly simplifies several language features – Java has automatic memory management • Does Windows and takes out the garbage • No dangling pointers. No memory leaks. • A problem for real-time programs – Java simplifies pointer handling • No explicit reference/dereference operations • Everything is a pointer (like Lisp) – No makefiles – No header files – C++ syntax streamlined
  • 8. www.corewebprogramming.com Java is Powerful? • Truth: Java has a rich set of standard libraries – Networking – Threads (lightweight processes) – Distributed objects – Database access – Graphics: GUI controls and drawing – Data structure library – Arbitrary precision integral and fixed-point arithmetic – Digital signatures – Serialization (transmitting/reassembling data structures) – File and stream compression
  • 9. www.corewebprogramming.com Java is Powerful? • Myth: Java will increase programmer productivity for all applications by XXX%. • Myth: Java will kill C++ • Myth: All software should be written in Java – Unix utilities: C – Small/medium Windows-only programs: Visual Basic – String parsing: Perl – High-performance, single-platform OO systems: C++ – Air traffic control, aircraft flight software: Ada – Knowledge-based systems: Lisp/CLOS
  • 10. www.corewebprogramming.com Key Java Packages and Protocols • Core Technologies – JDBC – RMI – Jini (Device Networking) – JavaBeans – Swing – Java 2D • Standard Extensions – Servlets and JavaServer Pages (JSP) – Enterprise Java Beans – Java 3D
  • 11. www.corewebprogramming.com Java Packages and Protocols: JDBC (Java DataBase Connectivity) • Standardizes mechanism for making connection to database server – Requires server-specific driver on client. No change to server. • Standardizes mechanism for sending queries – Either regular or parameterized queries (stored procedures) • Standardizes data structure of query result – Assumes relational data, so data structure is a table • Does not standardize SQL syntax – Queries are simply strings – Server extensions and enhancements supported
  • 12. www.corewebprogramming.com Java Packages and Protocols: Remote Method Invocation (RMI) • Built-in Distributed Object Protocol – RMI lets a developer access a Java object and manipulate it in the normal manner. Behind the scenes, each function call really goes over the network to a remote object. – Arbitrary Java data structures can be sent over the network with little or no special packaging, due to Java’s “serialization” mechanism – Similar to a simplified CORBA, but restricted to Java-to-Java communication • Jini – RMI-based protocol for self-documenting services. – Allows real “plug and play” devices -- no separate drivers – Jury is out on eventual success. Security and industry adoption are open questions.
  • 13. www.corewebprogramming.com Java Packages and Protocols: JavaBeans • JavaBeans is to Java as ActiveX is to Visual C++. – Lets you package a Java program as a software “component” – Visual tools can modify/manipulate it without knowing anything about it in advance • For example, you can drop a Bean into Visual Café, IBM VisualAge for Java, Inprise (Borland) JBuilder, Sybase PowerJ, Metrowerks CodeWarrior, Sun JavaWorkshop, etc., and it is automatically available from their tool palette for drag-and-drop development – Better security and portability than ActiveX – More ActiveX components available
  • 14. www.corewebprogramming.com Java Packages and Protocols: Swing • Standard GUI-control (widget) library in Java 2 • Many more built-in controls • Much more flexible and customizable • Includes many small features aimed at commercial applications – Tooltips, tabbed panes, on-line help, HTML support, dockable toolbars, multi-document interface, etc. • Look and feel can be changed at run time
  • 15. www.corewebprogramming.com Java Packages and Protocols: Servlets and JavaServer Pages (JSP) • Servlets: Java’s answer to CGI – Efficient: thread, not process, per request – Convenient: HTTP headers, cookies, etc. – Powerful: persistence, session tracking, etc. – Secure: no buffer overflows or shell escapes • Supported by virtually all Web servers: – Native support: Netscape/iPlanet, IBM WebSphere, Oracle 8i/9i and Oracle Application Server, BEA WebLogic, Silverstream, Sapphire/Web, etc. – Via add-on engine: Apache, Microsoft IIS and Personal WebServer, Netscape FastTrack, O’Reilly WebSite, StarNine WebSTAR for MacOS, etc. • JavaServer Pages (JSP) – Convenient and efficient way to combine servlets and HTML. Portable alternative to ASP & ColdFusion.
  • 16. www.corewebprogramming.com Java Packages and Protocols: Enterprise JavaBeans (EJB) • EJBs are to server components what regular JavaBeans are to application components • Standardizes access to services like load balancing, persistence, failover, etc. • Builds on JavaBeans, CORBA, and RMI “under the hood” • Potentially accessible via non-Java programs • Application Servers Supporting EJB – BEA WebLogic, IBM WebSphere, Netscape, Oracle, Progress SW Apptivity, NetDynamics, Sybase, Bluestone Saphire/Web etc.
  • 17. www.corewebprogramming.com Basic Hello World Application • “Application” is Java lingo for a stand-alone Java program – Note that the class name and the filename must match – A file can contain multiple classes, but only one can be declared public, and that one’s name must match the filename • File HelloWorld.java: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world."); } }
  • 18. www.corewebprogramming.com Basic Hello World Application (Continued) • Compiling: javac HelloWorld.java • Running: java HelloWorld • Output: Hello, world.
  • 19. www.corewebprogramming.com Command Line Arguments • File ShowArgs.java: public class ShowArgs { public static void main(String[] args) { for(int i=0; i<args.length; i++) { System.out.println("Arg " + i + " is " + args[i]); } } }
  • 20. www.corewebprogramming.com Command Line Arguments, Results • Compiling and Running: > javac ShowArgs.java > java ShowArgs fee fie foe fum Arg 0 is fee Arg 1 is fie Arg 2 is foe Arg 3 is fum
  • 21. www.corewebprogramming.com Basic Hello WWW Applet • File HelloWWW.java: import java.applet.Applet; import java.awt.*; public class HelloWWW extends Applet { public void init() { setBackground(Color.gray); setForeground(Color.white); setFont(new Font("SansSerif", Font.BOLD, 30)); } public void paint(Graphics g) { g.drawString("Hello, World Wide Web.", 5, 35); //5=left, 35=bottom } }
  • 22. www.corewebprogramming.com Basic Hello WWW Applet (Continued) • File HelloWWW.html: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>HelloWWW: Simple Applet Test.</TITLE> </HEAD> <BODY> <H1>HelloWWW: Simple Applet Test.</H1> <APPLET CODE="HelloWWW.class" WIDTH=400 HEIGHT=40> <B>Error! You must use a Java enabled browser.</B> </APPLET> </BODY> </HTML>
  • 23. www.corewebprogramming.com Basic Hello WWW Applet (Continued) • Compiling: javac HelloWWW.java • Running: Load HelloWWW.html in a Java-enabled browser
  • 24. www.corewebprogramming.com Customizing Applets with PARAM import java.applet.Applet; import java.awt.*; public class Message extends Applet { private int fontSize; private String message; public void init() { setBackground(Color.black); setForeground(Color.white); fontSize = getSize().height - 10; setFont(new Font("SansSerif", Font.BOLD, fontSize)); // Read heading message from PARAM entry in HTML. message = getParameter("MESSAGE"); } public void paint(Graphics g) { if (message != null) g.drawString(message, 5, fontSize+5); } }
  • 25. www.corewebprogramming.com Customizing Applets with PARAM, cont. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>The Message Applet</TITLE> </HEAD> <BODY BGCOLOR="WHITE"> <H1>The <CODE>Message</CODE> Applet</H1> <P> <APPLET CODE="Message.class" WIDTH=325 HEIGHT=25> <PARAM NAME="MESSAGE" VALUE="Tiny"> <B>Sorry, these examples require Java</B> </APPLET> <P> <APPLET CODE="Message.class" WIDTH=325 HEIGHT=50> <PARAM NAME="MESSAGE" VALUE="Small"> <B>Sorry, these examples require Java</B> </APPLET> ... </BODY> </HTML>
  • 27. www.corewebprogramming.com Summary • Java is a complete language, supporting both standalone applications and Web development • Java is compiled to bytecode and can be run on any platform that supports a Java Virtual Machine • Java 2 Platform is available in a Standard Edition, Enterprise Edition, or Micro Edition • Compiling: use “javac” • Executing standalone programs: use “java” • Executing applets: load HTML file in browser