IT-231 Java Programing

2.Introduction to Java Programming
A.History
Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is general-purpose, concurrent, class-based, and object-oriented, and is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere". Java is considered by many as one of the most influential programming languages of the 20th century, and is widely used from application software to web applications.
OAK-is the first name of Java

Genesis of java
James Gosling
Patrick Naugton
Chist Worth
Ed Frank
Mike Shireden

Two type of java program
1.Appication
2.Applet

Tokens is the smallest individual unit of programming written in array progrmming
java Tokens are devided into
1.Special Symbols
2.Word Symbols
3.Identifier

B.Java technology:

a.Programming laguage-A set of rules,symbols and special words used to construct programs

b.Development Environment
-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.

c.Application Environment
-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

d.Deployment Environment
-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.

C.Java Features
a.Java Virtual Machine
Java Virtual Machines operate on Java bytecode, which is normally (but not necessarily) generated from Java source code; a JVM can also be used to implement programming languages other than Java. For example, Ada source code can be compiled to Java bytecode, which may then be executed by a JVM. JVMs can also be released by other companies besides Sun (the developer of Java) — JVMs using the "Java" trademark may be developed by other companies as long as they adhere to the JVM specification published by Sun (and related contractual obligations).

The JVM is a crucial component of the Java Platform. Because JVMs are available for many hardware and software platforms, Java can be both middleware and a platform in its own right[clarification needed] — hence the trademark write once, run anywhere. The use of the same bytecode for all platforms allows Java to be described as "compile once, run anywhere", as opposed to "write once, compile anywhere", which describes cross-platform compiled languages. The JVM also enables such features as Automated Exception Handling that provides 'root-cause' debugging information for every software error (exception) independent of the source code.

The JVM is distributed along with a set of standard class libraries that implement the Java API (Application Programming Interface). An application programming interface is what a computer system, library or application provides in order to allow data exchange between them. They are bundled together as the Java Runtime Environment.


b.garbage Collection
-responsible for freeing any memory that can be freed. This happens automatically during the lifetime of the Java program.–programmer is freed from the burden of having to deallocate that memory themselves

c.Code Securety
-is attained in Java through the implementation of its Java Runtime Environment (JRE). ●JRE –runs code compiled for a JVM and performs class loading (through the class loader), code verification (through the bytecode verifier) and finally code execution
●Class Loader–responsible for loading all classes needed for the Java program–adds security by separating the namespaces for the classes of the local file system from those that are imported from network sources–After loading all the classes, the memory layout of the executable is then determined. This adds protection against unauthorized access to restricted areas of the code since the memory layout is determined during runtime
Bytecode verifier–tests the format of the code fragments and checks the code fragments for illegal code that can violate access rights to objects


D.Phases of Java Programming
a.write
-A logic error arises when the programmer has written code that compiles and executes normally, but the machine's behavior does not correspond with the original concept. An example of a logic error would be if a program intends to identify when the user clicks on a shape in the window, but the program fails to include clicks on the shape's outermost boundary.

b.compile
- Compile – during this phase, the programmer compiles the program using a command at the command line, or tools from the IDE. At this step, the Java source code is translated into bytecodes. If you are running the Java compiler from the command prompt, the command to enter is:

Command: javac HelloWorld.java*
*Below we will see common errors using the compiler.

Running the command above would compile the Java source file, HelloWorld.java, and generate a bytecode class file named, HelloWorld.class.


c.Run
-A run-time error occurs during execution; one example of a common run-time error is when the machine code instructs the computer to divide a number by zero. Often such errors crash the program; that is, execution stops abruptly.

E.Difference between Java applications and Java applets

a. Java applications
- is dependent in the sense it can perform and manipulate date without intervention from other application.The concept of Write-once-run-anywhere (known as the Platform independent) is one of the important key of java application that makes java as the most powerful language. Not even a single language is idle to this feature but java is more closer to this feature.

b.Java applets is a special type of java program that is executed via the internet
-it is tyoecal run on the web browser such as Netscape Navigator,Mozilla firefax etc.
-Applets are not allowed access to computer on which they are being run for security reason.

F.What makes Java an object oriented programming language
-Object-oriented programming is at the core of Java. In fact, all Java programs are object-
oriented—this isn't an option the way that it is in C++, for example. OOP is so integral to
Java that you must understand its basic principles before you can write even simple Java
programs. Therefore, this chapter begins with a discussion of the theoretical aspects of
OOP.
0 Responses