JAVA Language


Name: JAVA Language

Designed By : James Gosling

Developed By : Sun Microsystems, Oracle Corporation

First Appeared in : 1995

Usual Filename Extension : .java, .class, .jar
Introduction:

         Java is a general purpose object oriented programming language developed by Sun Microsystems of USA in 1991, originally called oak by James Gosling, one of the inventors of the language. The most striking feature of the language is that it is a platform natural language. Java is the 1st programming language i.e. not tied to any particular hardware or operating system. Programs developed in Java can be executed anywhere on any system. Java is not only reliable, portable and distributed but also simple, compact and interactive language.
         Through Java language two types of programs can be developed- Stand alone programs which are written in Java to carry out certain task on standalone local computer and web applets which are small java programs developed for internet applications.

Why A Cup Of Coffee Is The Logo Of Java:

         It is Because "Java" is one of many slang words for coffee".

History Of JAVA

         Java was designed for the development of software for consumer electronic devices like TV, VCR, Toaster and such other electronic machines. This goal had a strong impact on the development team to make the language simple, portable and highly reliable. List of some impact milestones in the development of Java is given below –

1990 – Sun Microsystems decided to develop special software that could be used to manipulate consumer electronic devices. A team of Sun Microsystems programmers headed by James Gosling was formed to undertake this task.

1991- After exploring the possibility of using the most popular object oriented language C++ the team announced a new language named oak.

1992- The team known as Green Project Team by Sun demonstrated the application of their new language to control a list of home appliances using a handheld device with a tiny touch sensitive screen.

1993- The World Wide Web appeared on the internet and transformed the text based internet into a graphical rich environment. The green project team came up with the idea of developing web applets (tiny programs) using the new language that could run on all types of computer connected to internet.

1994- The team developed a web browser called hot java to locate and run applet program on internet. “Hot Java” demonstrated the power of the new language. This makes it instantly popular among the internet users.

1995- Oak was renamed “Java”. Many popular companies including Netscape and Microsoft announced their support of Java.

1996- Java established itself not only as a leader for internet programming but also as a general purpose object oriented programming language.


Characteristics of JAVA :
  1. Java is easy to write and learn, because most of the concepts are drawn from C++ language.

  2. It has a concise set of features that makes it easy to learn and use.

  3. Java provides a secure way to access web applications.

  4. Java uses Java Virtual Machine (JVM) to interpret the program code (byte code) on any platform.

  5. Java has both compiler and interpreter. Firstly, Java compiler compiles the source code into byte code and then this machine independent byte code interpreted into the machine language using JVM.

  6. Java is pure Object Oriented Programming. It provides most of the object oriented features.

  7. Java encourages error free programming by being strictly typed and performing runtime checks.

  8. Java is a Machine Independent Language i.e. Java is independent of hardware.

  9. Byte codes are highly optimized. JVM can execute them much faster as a result of which Java gives high performance.

  10. Java is designed as a distributed language for creating application on network. Java application can open and access remote object on internet as easily as they can do in a local system.

  11. Familiarity is another specific feature of Java to make the language look familiar to the existing programmer.

Features of Java :
  1. Compiled and interpreted
  2.          Java has both compiler and interpreter. Firstly, Java compiler compiles the source code into byte code and then this machine independent byte code interpreted into the machine code by the help of Java Virtual Machine (JVM).

  3. Platform independent and Portable
  4.          Java programs can be easily moved from one computer system to another, anywhere and anytime. Changes and upgrades in operating system processors and system resource will not force any changes in Java programs.

  5. Object Oriented
  6.          Java is pure Object Oriented Programming. It provides most of the object oriented features. Almost everything in Java is an object. Java comes up with an extensive set of classes arranged in packages that we can use in programs by inheritance.

  7. Robust and Secure
  8.          It provides many safeguards to ensure reliable codes. It has strict compile time and run time checking for data types. Java also incorporates the concept of exception handling which capture serious errors and eliminates any risk of crashing the system.
             Java also provides the feature to secure the language used for programming on the internet. Java system, not only verify all memory access but also ensure that no viruses are communicated with applet. The absence of pointer in Java ensures that programs can not gain access to memory locations without proper authorization.

  9. Familiar, Simple and Small
  10.           Familiarity is another specific features of Java to make the language look familiar to the existing programmer. Java is simplified version of C++.

  11. Distributed
  12.          Java is designed as a distributed language for creating application on network. Java application can open and access remote object on internet as easily as they can do in a local system. This enables multiple programmers at multiple remote locations to collaborate and work together on a single project.

  13. Multithreaded and interactive
  14.          Multithreaded means handling multiple tasks simultaneously i.e. there is no need to wait for the application to finish one task before beginning another one. This feature greatly improves the interactive performance of graphical applications.

  15. High Performance
  16.           Java performance is impressive for an interpreted language mainly due to the use of intermediate byte code. Java architecture is also designed to reduce overhead during runtime. Further the incorporation of multithreading enhance overall execution speed of java programs.

  17. Dynamic and extensible
  18.          Java is capable of dynamically linking in new class library, methods and object. Java programs support functions written in other language such as C and C++.These functions are called native methods which are linked dynamically at run time. This facility enables the programmer to use the efficient functions available in these languages.

Rules for writing a JAVA program:

       Some rules which hold for all programs written in JAVA language are as follow:
  1. Java doesn’t have any preprocessor and therefore we cannot use #define, #include and #ifdef statements. Instead of it, Java uses number of import statements.

  2. Java specifies package statements which declare a package name and inform the compiler that the classes define here belongs to this package.

  3. Use (/*-------*/) for single line comment, (//) for multiline comment and (/**--------*/) for documentation comment.

  4. Classes are primary and essential element of a java program. Java Standalone program uses multiple class definitions whereas applet code uses services of two classes namely Applet and Graphics from the Java class library essentially.

  5. Java Standalone program requires main method as a starting point. It creates objects of various classes and establishes communication between them. On reaching the end of main, the program terminates and the control passes back to the operating system.

  6. Java applets when loaded automatically called certain methods of applet class to start and execute applet code.

  7. Applets are run from inside a web page using the special feature known as <html> tag.
Code for printing “Hello World” in Java:
Code for Standalone Program:

Class SampleOne
{
	public static void main(String []args)
	{ 
    	System.out.println(“ Hello World ”);
	}
}

Code for Web Applet:
import java.awt.*;
import java.applet.*;
public class HelloWorld extends Applet
{
	public void paint(Graphics g)
  	{
    	g.drawstring(“Hello World”,10,100);
	}
}