hi folks,

No More fear of pointers........


Break the old rhythm.Explore the new horizons.


Be a crew member to the new ship......


get easy solutions to solve ur programming issues



WELCOME TO THE WORLD OF JAVA

Comments in Java Code

/**
@author:surendranadh reddy
* The HelloWorldApp class implements an application that

* simply displays "Hello World!" to the standard output.

*/

class HelloWorldApp

{

public static void main(String[] args)

{

System.out.println("Hello World!"); //Display the string.

}

}



The Java language supports three kinds of comments:

/* text */

The compiler ignores everything from /* to */.



/** documentation */

This indicates a documentation comment (doc comment, for short). The compilerignores this kind of comment, just like it ignores comments that use /* and */.



// text

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

Developing the Java Application

A Java application is a standalone Java program-- a program written in the Java language that runs independently of any browser.


Example:

/**
@ surendranadh reddy
* The HelloWorldApp class implements an application that

* simply displays "Hello World!" to the standard output.

*/

class HelloWorldApp

{

public static void main(String[] args)

{

System.out.println("Hello World!"); //Display the string.


}


}

output:

Java Development Kit

The Java Development Kit comes with a collection of tools that are used for developing and running Java programs. They include:


• appletviewer ( for viewing Java applet)

• javac (Java compiler)

• java (Java Interpreter)

• javap (Java disassembler)

• javah (for C header files)

• javadoc (for creating HTML documents)

• jdb (Java debugger)

The below figure depicts a Java program, such as an application or applet, that's running on the Java platform. As the figure shows, the Java API and Virtual Machine insulates the Java program from hardware dependencies.

The Java Platform

A platform is the hardware or software environment in which a program runs. 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. Most other platforms are described as a combination of hardware and operating system.
The Java platform has two components:

 • The Java Virtual Machine (Java VM)
• The Java Application Programming Interface (Java API)

The Java VM is the base for the Java platform and is ported onto various hardware-based platforms.
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 (application programming interface) is grouped into libraries (packages) of related components.

JAVA PROGRAMMING LANGUAGE

Java is also unusual in that each Java program is both compiled and interpreted.

With a compiler, it translates a Java program into an intermediate language called Java bytecodes--the platform-independent codes interpreted by the Java interpreter.
With an interpreter, each Java bytecode instruction is parsed and run on the computer. Compilation happens just once; interpretation occurs each time the program is executed. This figure show how it works.
The Java bytecodes is the machine code instructions for the Java Virtual Machine (Java VM). Every Java interpreter, whether it's a Java development tool or a Web browser that can run Java applets, is an implementation of the Java VM. The Java VM can also be implemented in hardware.

Java bytecodes help make "write once, run anywhere" possible.
One can compile your Java program into bytecodes on any platform that has a Java compiler. The bytecodes can then be run on any implementation of the Java VM.

HOW JAVA WORKS

To develop and distribute a Java program

1. Programmer codes Java source statements

2. Java compiler converts source statements into bytecode (platform-independent object language)

3. Bytecode is copied to the target platform

 To execute a Java program

1. Platform-dependent Java Virtual Machine (JVM) software must be installed

2. A copy of the JVM is started

3. Each bytecode statement is interpreted (translated) by the JVM into platform-dependent machine language and executed under JVM control.

Benefits of Java over C and C++

• Architecturally neutral. Once written, the same Java program can be run on any


platform computer and operating system) that supports Java.

• Entirely object-oriented. Existing code can be easily re-used and maintained.

• Secure. Dangerous program actions are prohibited.

• Supports Internet programming. Java applets are run by Web browsers.

• Robust. Language features and packaged code support graphical programming,
   exception handling, networking, multi-threading, I/O, and more.

Search This Blog