Escolar Documentos
Profissional Documentos
Cultura Documentos
History
2
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office. It was later renamed Java, from Java coffee, said to be consumed in large quantities by the language's creators.
Java Milestones
3
Year 1990
Development Sun decided to developed special software that could be used for electronic devices. A project called Green Project created and head by James Gosling. Team announced a new language named Oak The team demonstrated the application of their new language to control a list of home appliances using a hand held device. The World Wide Web appeared on the Internet and transformed the text-based interface to a graphical rich environment. The team developed Web applets (time programs) that could run on all types of computers connected to the Internet.
1991 1992
1993
Java Milestones
4
Year 1994
Development The team developed a new Web browsed called Hot Java to locate and run Applets. HotJava gained instance success. Oak was renamed to Java, as it did not survive legal registration. Many companies such as Netscape and Microsoft announced their support for Java Java established itself it self as both 1. the language for Internet programming 2. a general purpose OO language. A class libraries, Community effort and standardization, Enterprise Java, Clustering, etc..
1995
1996
1997-
Simple and Powerful Safe Object Oriented Robust Architecture Neutral and Portable Interpreted and High Performance Threaded Dynamic
Java Attributes
6
Familiar, Simple, Small Compiled and Interpreted Platform-Independent and Portable Object-Oriented Robust and Secure Distributed Multithreaded and Interactive High Performance Dynamic and Extensible
JAVA Attributes
7
Java Attributes
Many features of C and C++ that are either redundant or sources of reliable code are not part of Java. To make the language look familiar to the existing programmers, it was modelled on C and C++ Languages.
Programmer
Source Code Text Editor .java file Notepad, emacs,vi javac Compiler
Compiled Languages
10
Programmer
JAVA COMPILER
(translator)
JAVA INTERPRETER
(one for each different system)
Windows 95
Macintosh
Solaris
Windows NT
Platform independence
12
Java applications are written as text files The java compiler creates platform independent code which is called bytecode. Bytecode can be executed by the java runtime environment. The Java virtual machine is a program which knows how to run the bytecode on the operating system the JRE is installed upon. The JRE translates the bytecode into native code, e.g. the native code for Linux is different then the native code for Windows.
Java code
is compiled to produce
byte code
Java Compiler - Java source code (file with extension .java) to bytecode (file with extension .class) Bytecode - an intermediate form, closer to machine representation A interpreter (virtual machine) on any target platform interprets the bytecode.
Porting the java system to any new platform involves writing an interpreter. The interpreter will figure out what the equivalent machine dependent code to run. Size of primitive data types are machine independent
Core Classes
language Utilities Input/Output Low-Level Networking Abstract Graphical User Interface
Internet Classes
TCP/IP Networking WWW and HTML Distributed Programs
Object Oriented
17
Java is a true object oriented language . Almost everything in Java is an Object Features of Object Oriented Programming :
1. Object 2. Class 3. Data Abstraction 4. Encapsulation 5. Inheritance 6. Polymorphism 7. Binding
Ms. Asma A. Mokashi, Lecturer, MCA
Feature
Encapsulation Inheritance Multiple Inherit. Polymorphism Binding (Early or Late) Concurrency Garbage Collection Genericity Class Libraries
Robust :
1. It has strict compile time and runtime checking for data types . 2. Garbage Collection- Relieving programmers virtually all memory management problems 3. Exception Handling Which captures series of errors and eliminates any risk of crashing the system.
20
Secure :
1. Java system verify all memory access 2. Also ensues that no viruses are communicated with an applet. 3. The absence of pointers in Java ensures that programs cannot gain access to memory locations without proper authorization.
Distributed
21
Java is designed as a language for creating applications on networks. It has the ability to share both data and programs . Java applications can open and access remote objects on internet . This enables multiple programmers at multiple remote locations to collborates and work together on a single project.
Ms. Asma A. Mokashi, Lecturer, MCA
Multithreaded means handling multiple task simultaneously. This means that we need not wait for the application to finish one task before beginning another. This features greatly improves the interactive performance of graphical applications.
High Performance
23
Java performance is impressive for an interpreted langauge , mainly due to the use of intermediate bytecode. Incorporation of multithreading enhances the overall execution speed of Java Programs.
Java is capable of dynamically linking in new class libraries, methods, and objects. Java programs support functions written in other languages such as C and C++. these function are known as native methods Native mthods are linked dynamically at runtime.
25
Hello Java!
26
A simple Java Program The virtual machine will start the main method of this class if called via java HelloWorld
class HelloWorld { public static void main (String[] args) { System.out.println(Hello Java!); } }
The filename must be equal to the class name. The extension must be .java.
WS 08/09
import java.util.*; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, Java "); } }
All code must be inside a named class & the filename must match the classname exactly (case-sensitive)
1. // 2. /* */
Implementation comments: tells a programmer reading your code about your implementation Documentation comments: used by javadoc to generate info for users of your classes
1. /** */
Similar to #include in import java.lang.*; C/C++; but only loads a class public class HelloWorld { dynamically, if needed at public static void main(String[] args) { runtime
Step 1: compile into bytecodes javac HelloWorld.java Step 2: run java HelloWorld
Java programs are not compiled to machine code in the same way as conventional programming language. To support safe execution of compiled code on multiple platforms (portability, security), they are compiled to instructions for an abstract machine called the Java Virtual Machine (JVM).
The JVM is a specification originally published by Sun Microsystems. JVM instructions are called Java byte codes. They are stored in a class file. Ms. Asma A. Mokashi, Lecturer, MCA The JVM is a program that runs on a real computer. So any compiled Java program (class file) can be run on any
JIT
37
In one form of Just-In-Time compilation, methods may be compiled to machine code immediately before they are executed for the first time. Then subsequent calls to the method just involve jumping into the machine code. The JIT compiler reads the bytecodes in many sections (or in full rarely) and compiles them interactively into machine language so the program can run faster. Java performs runtime checks on various sections of the code and this is the reason Ms. Asma A. Mokashi, Lecturer, MCA the entire code is not compiled at once.[
Java Tokens
38
Keywords
39
abstract boolean break byte case catch char class const * continue default do double else extends final finally float for goto * if implements import instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient try void volatile while
Ms. Asma A. Mokashi, Lecturer, MCA
40
Data types
41
byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of 128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.
Ms. Asma A. Mokashi, Lecturer, MCA
short: The short data type is a 16-bit signed two's complement integer. It has a minimum value of -
42
float: The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in section 4.2.3 of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead. Numbers and Strings covers BigDecimal and other Ms. Asma A. Mokashi, Lecturer, MCA useful classes provided by the Java platform.