overview of java cs 3250. a brief history january 1996: first official release jdk 1.0 web: applets,...

41
Overview of Java CS 3250

Upload: brianna-cooper

Post on 28-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Overview of Java

CS 3250

Page 2: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

A Brief HistoryJanuary 1996:

first official release JDK 1.0

Web: applets, security, URL, networking

GUI: Abstract Windows Toolkit (AWT)

"To be blunt, Java 1.0 was not ready for prime time."

Core Java, Vol. I, p. 9

Page 3: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

A Brief History(continued)

February 1997: JDK 1.1

Authentication: digital signatures, certificates

Distributed computing: RMI, object serialization, Java IDL/CORBA

Database connectivity: JDBC

Component architecture: JavaBean Version 1.1 "filled in the most obvious gaps, greatly improved the reflection capability, and added a new event model for GUI programming. It was still rather limited, though."

Core Java, Vol. I, p. 9

Page 4: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

December 1998:

Java 2 Platform (JDK 1.2)

Standard, Enterprise, and Micro Editions

JFC: Swing, Java2D, Java3D

Java Cryptography Extension (JCE)

Enterprise computing: enterprise JavaBean (EJB), servlets, Java server page (JSP), Jini, XML

A Brief History(continued)

Page 5: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

More changes in 1.2 (Java 2):

Java Multimedia Framework (JMF)Embedded systems: KVM, JavaCard Performance enhancement: JIT, HotSpot VM

A Brief History(continued)

Version 1.2 "replaced the early toylike GUI and graphics toolkits with sophisticated and scalable versions that came a lot closer to the promise of 'Write Once, Run Anywhere' than their predecessors."

Core Java, Vol. I, p. 10

Page 6: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Versions 1.3 and 1.4:

incremental improvements to library, performance

bug fixes

A Brief History(continued)

"During this time, much of the initial hype about Java applets and client-side applications abated, but Java became the platform of choice for server-side applications."

Core Java, Vol. I, p. 10

Page 7: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Versions 5.0 (originally 1.5):

significant changes to language, not just library

generic classes

features inspired by C#"for each" loop, autoboxing, metadata

A Brief History(continued)

"Language changes are always a source of compatibility pain, but several of these new language features are so seductive that we think programmers will embrace them eagerly."

Core Java, Vol. I, p. 10

Page 8: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Evolution of JavaVersion New Language Features Classes and

Interfaces

1.0 The language itself 211

1.1 Inner classes 477

1.2 None 1524

1.3 None 1840

1.4 Assertions 2723

5.0 Generic classes, "for each" loop, varargs, autoboxing, metadata, enumerations, static import

3270

based on p. 10 of Core Java, Vol. I

Page 9: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Top 10 Reasonsfor Using Java

Or, 10 ways to start an argument

Page 10: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

10. Garbage Collected

C and C++ are not, but most other modern languages are

Page 11: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

9. Visual Studio

Platform-specific

Version problems

Impossible to write a small program

Lack of support for command-line tools

Emacs, make, javac, java

Page 12: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

8. Multi-threaded

Runnable

synchronized

Page 13: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

7. Distributed

Socket classes

Remote Method Invocation (RMI)

Serialization

Page 14: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

6. GUI-less GUIs

Can make a GUI with just a text editor

Also, flexible GUIs (layouts)

Page 15: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

5. Jobs

Personally, I haven’t heard of a good way to measure this…

Page 16: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

4. Pervasive

http://code.google.com/android

“The Open Handset Alliance, a group of more than 30 technology and mobile companies, is developing Android: the first complete, open, and free mobile platform.”

Also servlets, applets, JSP, current phone platforms

Page 17: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

3. Linux, OS X

Architecture neutral

Page 18: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

2. Libraries

Thousands of classes

Comprehensive and useful documentation

Page 19: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

And the number one reason is. . .

Page 20: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

1. Portable, standard, and free Graphics and GUIs

Near misses:

wxWidgets (not standard, not particularly easy to use)

QT (not free or standard)

GTK (not standard)

.NET (not portable)

Page 21: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Top 10 reasons NOT to use Java

You can’t say I’m biased…

Page 22: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

10. Unity

Unity? Huh?

JavaScript, C#, Boo

Page 23: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

9. ReallyLongVariableNamesAndClassNamesForWhichJavaIsFamousOrInfamous

Page 24: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

8. Java is “hard to teach”

“Too many things that can’t be explained at the beginning”

Do you believe it?

Page 25: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

7. J2EE

But, some people think this is Java’s niche

Page 26: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

6. Java is the “new COBOL”

Do you believe it?

Page 27: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

5. Bad press

Overhyped, misconceptionsSee Professor Allison’s D paper

Page 28: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

4. Sun’s follies

ME (and not working with Palm)

Java Media Framework

Java 3D

Quicktime for Java (OK, that’s Apple’s)

Is Oracle doing any better?

Page 29: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

3. C# and the 900-pound gorilla

Page 30: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

2. Python, JavaScript

But, see Jython and Rhino

Maybe Ruby, D, and maybe even PHP (but not Perl)

Page 31: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

1. Performance

Not as fast as C++ or C#

Is it fast enough?

Page 32: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

What’s Missing(vs. C++)

Explicit pointers

Delete operator

Destructors

References (pass-by-reference)

Default arguments

Page 33: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

What’s Missing(vs. C++)

GlobalsLocal static dataOperator overloadingMultiple (implementation) inheritanceSeparation of declaration and definitionTemplates (“generics” added in 1.5)

Page 34: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

What’s NewEverything resides in a class

Data and functions

Garbage collectionFewer memory management headaches

Exceptions not optionalUnicode encodingPortable:

ThreadsNetworkingData sizes

Page 35: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Java Architecture

Java code is compiled into platform-independent “byte code” (“javac.exe”)

Each class in its own .class file

The Java Virtual Machine runs in the target environment (“java.exe”)

Interprets the byte codeAdvantage: portability (“write-once-run-anywhere”)Disadvantage: degraded performance

Page 36: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

JIT Compilation

“Just-in-time” compilation

The JVM has the JIT compiler compile the code into native machine code

10-20 times faster than classic JVM interpretation

Page 37: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

public class Hello{ public static void main (String[] args) { System.out.println("Hello, world"); }}

First Java Application

Every program must have at least one class

Source file must be class name plus ".java"

Page 38: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

public class Hello{ public static void main (String[] args) { System.out.println("Hello, world"); }}

First Java Application

The famous "magic formula" for the main method of a Java application:

Page 39: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Elements of Java Programs

Class: Hello

Method: main(...)

Statement: System.out.println(...)

Comments:

// a comment

/* another comment */

/** document comment */

Source file: Hello.java (case sensitive)

Page 40: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Development EnvironmentsJava SDK from Oracle

www.oracle.com/technetwork/java/javase/downloads/index.html

command-line tools: javac, java, etc.

no editor included

netBeans (netbeans.org)IDE, including Java beans (components)

Eclipse IDE (eclipse.org)– IDE

All of these are freeSee Ch. 2 and the web sites for more information.

Page 41: Overview of Java CS 3250. A Brief History January 1996: first official release JDK 1.0 Web: applets, security, URL, networking GUI: Abstract Windows Toolkit

Compile and Run an Appusing the Java SDK command-line tools • To compile:

javac Hello.java

• To run:

java Hello