Introduction to Java The objectives of this chapter are: To describe the key aspects of Java To describe the Java software development kit (SDK) To explain.

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Object Orientated Programming
Introduction to Java Kiyeol Ryu Java Programming Language.
Introduction to Java Programming, 4E
CS2200 Software Development Lecture: Java Platform Lecturer: Adrian O’Riordan Course Webpage:
For more Lectures and Notes Visit
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
Softsmith Infotech Installing and Configuring Tomcat.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Introduction to Java Programming with JBuilder 4
S.W. Ma/CIM/LWL41211/2 Prog. IIA Page 1 HKIVE (Lee Wai Lee Campus) Department of CIM Course : Year 2 Module : Programming IIA Textbook : Introduction.
JAVA OVERVIEW. Java  Originally from Sun Microsystem.  Main components of Java:  Java Programming Language Programming language used to write software.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Computer Programming 12 Mr. Jean March 19 th, 2013.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.2 Getting the Tools and Setting Up the Development.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
Introduction to Java Programming with Forte Y. Daniel Liang.
Introduce to Java. Outline History of Java History of Java Something about Java Something about Java Brief introduction to Java programming Brief introduction.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Session 1 Introduction to Java. Objectives Java Simplified / Session 1 / 2 of 32 Explain the history of Java Explain Java in brief List the types of Java.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Java and its Evolution. Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
23-October-2002cse JavaIntro © 2002 University of Washington1 Intro to Java CSE 413, Autumn 2002 Programming Languages
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Introduction to Java Programming. 2 Chapter 1 Introduction to Java and Forte F What Is Java? F Getting Started With Java Programming –Create, Compile.
Java – in context Main Features From Sun Microsystems ‘White Paper’
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Introduction to Programming 1 1 2Introduction to Java.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Introduction to JAVA Programming
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Computer System Structures
Object Oriented Programming in
Java™ 2 Platform Getting Started.
Chapter 1 Introduction to Computers, Programs, and Java
Introduction Enosis Learning.
Introduction Enosis Learning.
Getting Started ARCS Lab..
Installing and Configuring Tomcat
(Computer fundamental Lab)
Java History, Editions, Version Features
Chap 1. Getting Started Objectives
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Introduction to Java The objectives of this chapter are: To describe the key aspects of Java To describe the Java software development kit (SDK) To explain the function of the Java Virtual Machine To explain the difference between the Java language and its class library (API)

It is an object-oriented language developed by Sun in the mid 1990s. Original language called Oak Intended for embedded systems Unlike C++, it was developed from scratch. The syntax is very similar to C. Sun describes it as "A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multi-threaded and dynamic language." As unbelievable as it may sound, Java will not save the world! What is Java?

Object-Oriented Designed to support Object-Oriented concepts However, does contain non-Object-Oriented primitive data types Distributed Applications are constructed using objects. Objects can be distributed in multiple locations within a network environment. Extensive integration with TCP/IP Interpreted Java compiles to byte-code (not machine code). Byte code is interpreted. Most Java versions after 1.2 include a JIT (Just-In-Time) compiler which compiles byte code to machine code. What is Java? (cont)

Robust Memory management is done automatically Use of pointers is limited Secure All Java code subject to security model. Architecture-Neutral/Portable Compiled Java (byte code) will run on any platform which has a Java Virtual Machine The Java Virtual Machine is available for almost all platforms... Even mainframes. What is Java? (cont)

High-Performance Originally, Java's performance was poor. Now, Java's performance rivals C++. Multi-Threaded Processes contain multiple threads of execution. Similar to multi-tasking but all threads share the same memory space. Dynamic Makes heavy use of dynamic memory allocation. Classes can be dynamically loaded at any time. What is Java? (cont)

Java has been described as WORA (Write once, Run Anywhere) In most cases, this is true. Not always true with GUI. Doesn't always come for free. Can require a lot of testing. Because Java source code is compiled to byte code and the byte code is interpreted, Java code can be executed anywhere an interpreter is available. The "Interpreter" is call the Java Virtual Machine Platform Independence. How does Java do it?

Traditionally, source code had to be compiled for the target hardware and OS platform: The Java Virtual Machine. Source.cpp i386 binary SPARC binary PPC binary Windows Compiler Solaris Compiler Mac Compiler

Java source files (.java) are compiled to Java bytecode (.class) Bytecode is interpreted on the target platform within a Java Virtual Machine The Java Virtual Machine. Source.java i386 VM SPARC VM PPC VM Java Compiler Java Bytecode Source.class

The Java VM does more than interpret bytecode: The class loader loads appropriate java classes. Possibly from the network. All classes are verified to contain only legal bytecodes and not permitted any illegal stack or register usage. A SecurityManager can limit access to resources such as the local file system or the network. Any unreferenced memory (Objects) are returned to the system by the Garbage Collector thread. Many database servers, application servers, web servers and browsers contain a Java virtual machine eg: Oracle, Tomcat (web server), WebSphere (app server), BEA Weblogic (app server), and Netscape and IE. Java VM Responsibilities

The Java SDK comes in three versions: J2ME - Micro Edition (for handheld and portable devices) J2SE - Standard Edition (PC development) J2EE - Enterprise Edition (Distributed and Enterprise Computing) The SDK is a set of command line tools for developing Java applications: javac - Java Compiler java - Java Interpreter (Java VM) appletviewer - Run applets without a browser javadoc - automated documentation generator jdb - Java debugger The SDK is NOT and IDE (Integrated Development Environment) Command line only. No GUI. The Java Software Development Kit (SDK)

There are many IDEs available. Some are public domain and some are commercial: Symantic Visual Cafe JBuilder IBM Visual Age Kawa Forte for Java Many OO modelling tools (such as Together Control Center) include an IDE. Most IDEs offer a "demo" mode so you can try before you buy. Integrated Development Environments (IDEs)

Download from Sun Web-site: Select "J2SE downloads" Choose your version Select your platform Download will be an installer file appropriate for your platform: Installer.exe for windows rpm or self extracting file for linux tar or self extracting file for SPARC To install, execute the installer program or extract from tar file. Obtaining the Java SDK

You might notice, the full SDK is very large (>46 MB) If you only wish to run Java programs, you do not need to install the SDK. Instead, you can install the JRE: Smaller installer file Less time to download No compiler or development tools. Just Java VM and support libraries for specified platform. You can re-distribute the JRE installer. You CANNOT redistribute the Java SDK. Obtaining the Java Runtime Environment (JRE)

The Java language is quite small. Accompanying the language is a Class library (API) Contains core classes. Contains extensions to Java. The Java API takes a long time to learn. The API Documentation is available for download or can be viewed at: Note: This documentation is generated by javadoc Extended APIs include: Messaging API, Servlet API, Java2D, Java3D, Java Media Framework, JavaMail and more... Obtaining the Java API Documentation

When you view the Java API Documentation, you'll note that the classes are grouped into logical units called "Packages". Because there are so many classes, packages provide a mechanism for classifying classes so that they are easier to learn and use. Developers can also make use of packages to classify their own classes. This will be discussed later in the course. Packages

While it should be your goal to learn as many packages as you can, there are some packages you will use more than others: Commonly Used Packages Language (general) GUI Misc. Utilities and Collections Input/Output Networking java.lang java.awt java.awt.event javax.swing java.util java.io java.net Common classes used for all application development Graphical User Interface, Windowing, Event processing Helper classes, collections File and Stream I/O Sockets, Datagrams

Even though Java is not very old, there are several key versions to be aware of: Java First stable version. Not very useful. Java 1.1 (1997) Security, Database connectivity (JDBC), Improved Performance Most stable version Unstable versions and Java 1.2 (1998) MAJOR CHANGES Addition of Swing GUI (mostly replaces AWT) Improved Security Enterprise computing Java 1.3 (2000) Many extended APIs added Improved performance Java 1.4 (2002) Improved performance Bug Fixes Java Version History

HelloWorld.java Here is Java's "HelloWorld" implementation: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } In the file, HelloWorld.java:

Running HelloWorld To compile HelloWorld.java, use the compiler. If successful, it will produce a file called HelloWorld.class in the same directory. > javac HelloWorld.java [ compiler output ] To execute, run the Java VM and include the name of the class which contains the "main" method as the first command line parameter. > java HelloWorld Hello World note: do not include the.class extension output from program errors and warnings

What are the key features of Java? How does Java obtain platform independence? What is the Java Virtual Machine and what are its responsibilities? What is the Java SDK? What is the JRE? What is the Java API? What are packages? Review