Saturday, November 6, 2010

Java Basics

A, for example, the class loader searches the   CLASSPATH environment variable for a file called A.class
.
The following diagram shows an example of the Java compilation and execution
sequence for a source file named
class
Java programs are, in effect, distributed applications. You may think of them as a
collection of DLLs (dynamically loadable libraries) that are linked on demand at
runtime. When you write your own Java applications, you will often integrate
your program with already-existing portions of code that reside on other
machines.


Java Program Execution

The Java byte-code compiler translates a Java source file into machineindependent
byte code. The byte code for each publicly visible class is placed in a
separate file, so that the Java runtime system can easily find it. If your program
instantiates an object of class
directories listed in your
that contains the class definition and byte code for class A
There is no link phase for Java programs; all linking is done dynamically at

Thursday, November 4, 2010

Java Basics-3

Portability
Java programs are portable across operating systems and hardware environments.
Portability is to your advantage because:

• You need only one version of your software to serve a broad market.
• The Internet, in effect, becomes one giant, dynamic library.
• You are no longer limited by your particular computer platform.

Three features make Java  programs portable:
 
1. The language. The Java language is completely specified; all data-type sizes and
formats are defined as part of the language. By contrast, C/C++ leaves these
"details" up to the compiler implementor, and many C/C++ programs therefore are not portable.

2. The library. The Java class library is available on any machine with a Java
runtime system, because a portable program is of no use if you cannot use the
same class library on every platform. Window-manager function calls in a Mac
application written in C/C++, for example, do not port well to a PC.

3. The byte code. The Java runtime system does not compile your source code
directly into machine language, an inflexible and nonportable representation of
your program. Instead, Java programs are translated into machine-independent
byte code. The byte code is easily interpreted and therefore can be executed on
any platform having a Java runtime system. (The latest versions of the Netscape
Navigator browser, for example, can run applets on virtually any platform).


Security
The Java language is secure in that it is very difficult to write incorrect code or
viruses that can corrupt/steal your data, or harm hardware such as hard disks.

There are two main lines of defense:

• Interpreter level:
• No pointer arithmetic
• Garbage collection
• Array bounds checking
• No illegal data conversions
• Browser level (applies to applets only):
• No local file I/O
• Sockets back to host only
• No calls to native methods

 Robustness
The Java language is robust. It has several features designed to avoid crashes
during program execution, including:
• No pointer arithmetic
• Garbage collection--no bad addresses
• Array and string bounds checking
• No jumping to bad method addresses
• Interfaces and exceptions

Java Basics(java platform)

A platform is the hardware or software environment in which a program runs.We already know some of the most popular platforms like Microsoft Windows , Linux , Solaris OS,and Mac OS. Most patform differs from most other platforms in that it's a software-only platforms that runs on top of other hardware-based
platforms.
The Java platform has two Java  components :
# The Virtual Machine
#The Java Applications Programming Interface(API) 
The API is a large collection of  ready-made software components that provide many useful capabilities.It is grouped into libraries of related classes and interfaces;these libraries are known as  packages.
The API and JVM insulates the program from the underlying hardware.
As a platform independent environment, the java platform can be a bit slower than native code.

Java Basics

Java Basics-1
The Java programming language is a high level language that can be characterizedby all of the following buzzwords:
#Simple                #Architecture Neutral
#Object oriented #Portable
#Distributed        #High performance
#Multithreaded  #Robust
#Dynamic           #Secure


In java all source code is first written in plain text files ending with the .java extension.Those source files are then compiled into .class files by the javac compiler.A .class file does not contain code that is native to your processor,It instead contains bytecodes the the machine language of he Java Virtual Machine(JVM).The java launcher tool then runs your application with an instance of the JVM.