chapter 1 introduction to java technology

41
INTRODUCTION To JAVA PROGRAMMING JESS DALE DELA CRUZ CONTACT # 09267099110

Upload: sshhzap

Post on 17-May-2015

2.101 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Chapter 1 introduction to java technology

INTRODUCTION To JAVA PROGRAMMING

JESS DALE DELA CRUZ

CONTACT # 09267099110

Page 2: Chapter 1 introduction to java technology
Page 3: Chapter 1 introduction to java technology

ORIGINALLY CALLED OAK

Page 4: Chapter 1 introduction to java technology

JAMES ARTHUR GOSLING

Page 5: Chapter 1 introduction to java technology

FOR MORE INFORMATION VISIT HTTP://JAVA.SUN.COM

Page 6: Chapter 1 introduction to java technology
Page 7: Chapter 1 introduction to java technology
Page 8: Chapter 1 introduction to java technology
Page 9: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

SIMPLEJava was designed to make it much easier to write bug free code. Because Java is simple, it is easy to read and write. There aren't a lot of special cases or tricks that will confuse beginners. Java makes to providing bug-free code is automatic memory allocation and de allocation.

Page 10: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

OBJECT- ORIENTED

MORE OF THIS IN CHAPTER 2

Page 11: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

DISTRIBUTEDJava has an extensive library of routines for coping easily with TCP/IP protocols like HTTP and FTP. This makes creating network connections much easier than in C or C++. Java applications can open and access objects across the net via URLs with the same ease that programmers are used to when accessing a local file system.

Page 12: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

INTERPRETEDJava byte codes are translated on the fly to native machine instructions (interpreted) and not stored anywhere. And since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory.As a part of the byte code stream, more compile-time information is carried over and available at runtime. This is what the linker's type checks are based on. It also makes programs more amenable to debugging.

Page 13: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

ROBUST

robustness is its portability across many Operating systems, with is supported by the Java Virtual Machine.

Page 14: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

SECUREThe Java compiler catches more compile-time errors; other languages (like C++) will compile programs that produce unpredictable results.Java does not allocate direct pointers to memory. This makes it impossible to accidentally reference memory that belongs to other programs or the kernel.

Page 15: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

ARCHITECTURAL NEUTRALJava was designed to support applications on networks. In general, networks are composed of a variety of systems with a variety of CPU and operating system architectures. To enable a Java application to execute anywhere on the network, the compiler generates an architecture-neutral object file format--the compiled code is executable on many processors, given the presence of the Java runtime system.This is useful not only for networks but also for single system software distribution. In the present personal computer market, application writers have to produce versions of their application that are compatible with the IBM PC and with the Apple Macintosh. With the PC market (through Windows/NT) diversifying into many CPU architectures, and Apple moving off the 680x0 toward the PowerPC, production of software that runs on all platforms becomes nearly impossible. With Java, the same version of the application runs on all platforms.

Page 16: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

PORTABLE

The Java system itself is quite portable. The compiler is written in Java and the runtime is written in ANSI C with a clean portability boundary.

Page 17: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

HIGH PERFORMANCEWhile you'll never get that last ounce of speed out of a Java program that you might be able to wring from C or Fortran, the results will be suitable for all but the most demanding applications.It is certainly possible to write large programs in Java. The HotJava browser, the Eclipse integrated development environment, the LimeWire file sharing application, the jEdit text editor, the JBoss application server, the Tomcat servlet container, the Xerces XML parser, the Xalan XSLT processor, and the javac compiler are large programs that are written entirely in Java.

Page 18: Chapter 1 introduction to java technology

JAVA TECHNOLOGY

MULTI THREADING

This makes Java very responsive to user input. It also helps to contribute to Java's robustness and provides a mechanism whereby the Java environment can ensure that a malicious applet doesn't steal all of the host's CPU cycles.

Page 19: Chapter 1 introduction to java technology

JAVA TECHNOLOGY DYNAMIC

In a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving environment. For example, one major problem with C++ in a production environment is a side-effect of the way that code is implemented. If company A produces a class library (a library of plug and play components) and company B buys it and uses it in their product, then if A changes its library and distributes a new release, B will almost certainly have to recompile and redistribute their own software. In an environment where the end user gets A and B's software independently (say A is an OS vendor and B is an application vendor) problems can result.For example, if A distributes an upgrade to its libraries, then all of the software from B will break. It is possible to avoid this problem in C++, but it is extraordinarily difficult and it effectively means not using any of the language's OO features directly.By making these interconnections between modules later, Java completely avoids these problems and makes the use of the object-oriented paradigm much more straightforward. Libraries can freely add new methods and instance variables without any effect on their clients.

Page 20: Chapter 1 introduction to java technology

How to program JAVA

With the compiler, first you translate a program into an inter-mediate language called Java bytecodes—the platform-independent codes interpreted by the interpreter on the Java platform. The interpreter parses and runs each Java bytecode instruction on the computer. Compilation happens just once; interpretation occurs each time the program is executed.

Page 21: Chapter 1 introduction to java technology
Page 22: Chapter 1 introduction to java technology

HOW TO PROGRAM IN JAVA

Page 23: Chapter 1 introduction to java technology

JAVA PLATFORM

A platform is the hardware or software environment in which a program runs. We've already mentioned some of the most popular platforms, such as Windows 2000, Linux, Solaris, and MacOS. Most platforms can be described as a combination of the operating system and hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other, hardware-based platforms.

Page 24: Chapter 1 introduction to java technology

The Java platform has two Components:

The Java Virtual Machine (Java VM)

The Java Application Programming Interface (Java API)

Page 25: Chapter 1 introduction to java technology

Java Virtual Machine

It's the base for the Java platform and is ported onto various hardware-based platforms.

Page 26: Chapter 1 introduction to java technology

JAVA APPLICATION PROGRAMMING INTERFACE The Java API is a large collection of ready-

made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages. The next section highlights what functionality some of the packages in the Java API provide.

Page 27: Chapter 1 introduction to java technology

Types of programs written in the Java programming language APPLETS

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM). For information and examples on how to include an applet in an HTML page, refer to this description of the <APPLET> tag.

APPLICATIONSAn application is a standalone program that runs directly on the Java platform. A special kind of application known as a server serves and supports clients on a network. Examples of servers are Web servers,

mail servers, and print servers. SERVLETS

Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. A servlet can almost be thought of as an applet that runs on the server side--without a face. Java servlets make many Web applications possible.

Page 28: Chapter 1 introduction to java technology

NEW FEATURES IN JAVA Development Tools: The development tools provide everything you'll need for compiling,

running, monitoring, debugging, and documenting your applications. As a new developer, the main tools you'll be using are the javac compiler, the java launcher, and the javadoc documentation tool.

Application Programming Interface (API): The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to networking and security, to XML generation and database access, and more. The core API is very large; to get an overview of what it contains, consult the Java SE Development Kit 6 (JDKTM 6) documentation.

Deployment Technologies: The JDK software provides standard mechanisms such as the Java Web Start software and Java Plug-In software for deploying your applications to end users.

User Interface Toolkits: The Swing and Java 2D toolkits make it possible to create sophisticated Graphical User Interfaces (GUIs).

Integration Libraries: Integration libraries such as the Java IDL API, JDBCTM API, Java Naming and Directory InterfaceTM ("J.N.D.I.") API, Java RMI, and Java Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java RMI-IIOP Technology) enable database access and manipulation of remote objects.

Java Database Connectivity (JDBC™): Provides uniform access to a wide range of relational databases.

Page 29: Chapter 1 introduction to java technology

COMMENTS

/* text */

The compiler ignores everything from the opening /* to the closing */.

/** documentation */This style indicates a documentation comment (doc comment, for

short). As with the first kind of comment, the compiler ignores all the text within the comment. The SDK javadoc tool uses doc comments to automatically generate documentation.

// text

The compiler ignores everything from the // to the end of the line.

Page 30: Chapter 1 introduction to java technology

CLASS

A class is the basic building block of an object-oriented language, such as the Java programming language. A class is a blueprint that describes the state and the behavior associated with instances of that class. When you instantiate a class, you create an object that has the same states and behaviors as other instances of the same class. The state associated with a class or an object is stored in member variables. The behavior associated with a class or an object is implemented with methods, which are similar to the functions or procedures in procedural languages, such as C.

class Mammal { . . . //class definition block }

Page 31: Chapter 1 introduction to java technology

public static void main(String[] args)

The main method declaration starts with three modifiers:

public: Allows any class to call the main method static: Means that the main method is associated

with the HelloWorldApp class as a whole instead of operating on an instance of the class

void: Indicates that the main method does not return a value

Page 32: Chapter 1 introduction to java technology

System class

The System class provides system-independent access to system-dependent functionality. One feature provided by the System class is the standard output stream—a place to send text that usually refers to the terminal window in which you invoked the Java interpreter.

System.out.println("Hello World!");

Page 33: Chapter 1 introduction to java technology
Page 34: Chapter 1 introduction to java technology

Elements You can write in JAVA

All keywords are written as small letters so HUWAG NG MAKULIT!!!

Page 35: Chapter 1 introduction to java technology

Elements You can write in JAVA

Page 36: Chapter 1 introduction to java technology
Page 37: Chapter 1 introduction to java technology

Elements You can write in JAVA

Page 38: Chapter 1 introduction to java technology

Elements You can write in JAVA

Page 39: Chapter 1 introduction to java technology

Elements You can write in JAVA

Page 40: Chapter 1 introduction to java technology
Page 41: Chapter 1 introduction to java technology