180 likes | 312 Views
CS2200 Software Development Lecture: Java Platform. Lecturer: Adrian O’Riordan Course Webpage: http://www.cs.ucc.ie/~adrian/cs2200.html. Java Programming Language.
E N D
CS2200 Software DevelopmentLecture: Java Platform Lecturer: Adrian O’Riordan Course Webpage: http://www.cs.ucc.ie/~adrian/cs2200.html
Java Programming Language • Java is an object oriented programming language based on C and C-based object oriented languages such as C++ and Objective C. Mesa, Oberon, and Smalltalk were also influences. • Specifications of the Java language, the Java Virtual Machine (JVM) and the Java API are community-maintained through the Sun-managed Java Community Process. • The Java Runtime Environment (JRE) is the software required to run any application deployed on the Java platform. End-users commonly use a JRE in software packages and plugins. Sun distributes a superset of the JRE called the Java SDK which includes development tools such as the Java compiler, Javadoc, and debugger.
Features of Java • Simple – simpler than C++ • Architecture neutral bytecode intermediate format • Object oriented - from the ground up • Portable - standard specification • Distributed - Java platform • High performance - efficient • Multithreaded - built in synchronization primitives • Robust - extensive compile-time checking, followed by a second level of run-time checking and exception handling • Dynamic - run-time system, classes are linked only as needed • Secure - for networked environments • Web-enabled - Webstart, applets, and servlets • Popular and free - widely used • Tool support – many compilers, supporting IDEs, etc.
Example Feature: Java Garbage Collection • Basic variables have a predefined duration; objects do not • JVM manages memory for you - there is no facility to manually destroy objects in Java • Java collects “garbage” objects that are no longer needed - objects that no longer have any references to them • Un-used objects are not deleted immediately but • when JVM decides that the amount of free memory is low • when the program terminates • when you invoke System.gc() • Java's use of garbage collection can make Java unsuitable for time-critical applications • Contrast: C++ programmers have complete control over the allocation and de-allocation of memory
Java Limitations? • Look and feel of Swing – default is significantly different from native apps; new pluggable look and feel system of Swing allows different looks • Performance issues – although recent versions significantly faster than earlier ones and now has JIT compiler • Not fully object oriented – primitive types are not objects • Lack of some object oriented features – e.g. operator overloading and multiple inheritance • Java was subject to proprietary license – now free software and open source
Java Timeline I 1994. First made public as Oak programming language developed under James Gosling at Sun as part of a project codenamed Green. As a prototype, Patrick Naughton wrote a small web browser, WebRunner, later renamed HotJava. Oak was renamed Java. 1995. Achieved prominence following the announcement at 1995's SunWorld that Netscape would be including support for it in their Navigator browser. 1996. Initial release JDK 1.0. 1997 JDK 1.1 Released. Adds inner classes to core language. Also adds Java Beans, JDBC and RMI 1998. Version 1.2 introduces major changes including Swing graphical API, This and subsequent releases branded Java 2. JVM has a JIT compiler for the first time. Collections framework added.
Java Timeline II 2000. J2SE 1.4 released. Adds assert keyword, regular expressions, and Java WebStart among changes. 2004. Major new release Java 5 (Release 1.5) codename Tiger introduces a number of new features. • generics – type safe collections • annotations for metadata • autoboxing- automatic type conversions between promitive types • enumerations – ordered list of values • new for loop iterator syntax 2006 Java SE 6 released. Performance improvements. GUI improvements
Java Platforms Sun has defined three platforms targeting different application environments and segmented many of its APIs so that they belong to one of the platforms. The platforms are: • Java Platform, Micro Edition — targeting environments with limited resources, • Java Platform, Standard Edition — targeting workstation environments, and • Java Platform, Enterprise Edition — targeting large distributed enterprise or Internet environments. • The classes in the Java APIs are organized into separate groups called packages. Each package contains a set of related interfaces, classes and exceptions. • Java Platform, Standard Edition or Java SE is a collection of Java Application Programming Interfaces useful to any Java platform programs.
JDK Programmers can create Java applications using simple tools such as editors, and command line tools such as provided by Sun’s JDK (Java SE Development Kit). Basic tools include: • javac - compiler for the Java programming language • java - launcher for Java applications • javadoc - documentation generator • appletviewer - run and debug applets • jar - create and manage Java Archive (JAR) files • jdb - Java Debugger Many other tools for e.g. security, networking, monitoring
Java Virtual Machine I • runtime carries out emulation of the JVM instruction set by interpreting it; has a stack-based † architecture - each thread has its own stack and program counter • each particular host operating system needs its own implementation of the JVM and runtime. • verifies all bytecode before it is executed for security reasons - designed to allow safe execution of untrusted code from remote sources as in Java applets - remote code runs in a restricted sandbox †a model of computation in which the computer's memory takes the form of one or more stacks - data structures based on the principle of Last In First Out (LIFO)
Java Virtual Machine II HotSpot contains class loader, bytecode interpreter, Client and Server runtime compilers, garbage collectors, a set of supporting runtime libraries. Many JVM implementations, e.g. • HotSpot (Sun) • Kaffe (open source) • IBM J9 (IBM WebSphere) • IKVM.NET (free) • Apache Harmony (open source) Exists programming languages for the Java virtual machine aside of Java itself, e.g. AspectJ, JRuby, Groovy
Important packages • java.lang - fundamental classes and interfaces closely tied to the language and runtime system, including the root classes that form the class hierarchy, types tied to the language definition, basic exceptions, threading, and security functions; automatically imported into every source file. • java.io support for input and output - primarily streams • java.net - networking including HTTP requests • java.math - mathematics support • java.util - data structures and also Scanner class • java.awt and javax.swing – GUIs • java.applet – For creation of Web applets • java.sql – database access • java.beans – components • Java.net - networking
Java Libraries • Core libraries: • Collection libraries which implement data structures • XML Processing libraries • Security • Internationalization and localization libraries • Integration libraries, to communicate with external systems: • Java Database Connectivity (JDBC) for database access • Java Naming and Directory Interface (JNDI) for lookup and discovery • RMI and CORBA for distributed application development • User Interface libraries, which include: • The (heavyweight, or native) Abstract Windowing Toolkit • The (lightweight) Swing libraries, which are built on AWT but provide (non-native) implementations of the AWT widgetry • Java 2D and APIs for audio capture, processing, and playback
Java Technology Summary • Development Tools (JDK) – compiling (e.g. javac), running (e.g. java), documenting (javadoc), debugging (jdb) • APIs (Application Programming Interface) – library specs • Deployment Technology – applications, applets, JAR files, Web Start, plug-ins • User Interface and Graphics Toolkits – Swing, AWT, Java 2D • Integration Libraries – JDBC – database connect, Java RMI • Components, Enterprise Java – JavaBeans, Servlets, J2EE
Applets, Servlets and Java Web Start • Applets • included in an HTML page - <APPLET> tag • run in Web browser (requires a plugin) or JDK’s AppletViewer • in Java since the beginning • Used to provide interactive features to webpages • Servlets • Java Servlet allows addition of dynamic content to a Web server • JavaServer Pages (JSP) allows dynamic generation of HTML, XML or other types of documents in response to a Web client request • Java Web Start • started directly from the Internet using a web browser but do not run in the browser
Web refs • Java Beginnings – Early years at Sun • Java History – Feizabadi • 1996 White Paper • Java@Sun • Java Community Process • Java SE • Java EE • java.net Portal