Java is a general-purpose; object oriented programming language developed by Sun Microsystems in 1991. James Gosling and his team members developed Java. It was designed for the development of software for electronic devices like TVs, VCRs. The important features of java are as follows:
1) Java is both a compiled and an interpreted language
2) platform independent and portable
3) Object oriented language
4) Robust and secure
5) Distributed
6) High performance
7) Multithreaded and Interactive
Java Developer’s kit (JDK) - It Contains the basic tools and libraries necessary for creating, testing, documenting and executing java programs. There are seven main programs in JDK such as.
1) Javac - The java compiler
2) Java - The Java interpreter
3) Javadoc – It generates documentation in HTML.
4) Appletviewer - The Java interpreter to execute Java applets
5) Jdb - The Java Debugger to find and fix bugs in Java programs
6) Javap - The Java disassembler displays the accessible functions and data in a compiled class. It also displays the meaning of byte codes.
7) Javah - It creates interface between Java and c routines.
Tools Available for Java programming
API - The Application programming interface enables Java programmers to develop varieties of applets and applications. It contains six packages.
java.applet - For applet programming
java.awt - The abstract window toolkit for designing GUI likes Button, checkbox, choice, menu panel etc.
java.io - File input/output handling
java.lang – It provides useful classes to handle object, thread, Exception, String, system, math, Float, integer etc.
java.net – It contains classes for network programming, and supports TCP/IP networking protocols
java.util - It contains miscellaneous classes like vector, stack, list, date, dictionary etc.
Web browser - Java environment requires Java-enabled web browser to support java applets. Some popular java-enabled browsers are:
- Hot java from java soft web site (http://java.sun.com)
- Netscape Navigator from Netscape home page (http://home.nescape.com)
- Internet Explorer from Microsoft’s web page (http://www.microsoft.com)
Java IDE
There are number of IDEs (Integrated Development Environment) available to support the productivity of software development.
Java programs are available in two flavors:
1) Applet - A java applet is a program that appears embedded in a web document and applet comes into effect when the browser browses the web page
2) Application - It is similar to all other kind of programs like in c and c++. An application is required to solve a particular problem.
Simple Java program
Our first Java program is a simple application to print a message on the screen.
//Hello Java Application//
Class HelloWorldApp
{
Public Static void main(String args[])
{
System.out.println(“Hello Java!”);
}
}
How to edit this program?
Any text editor can be used to write Java programs. In windows Notepad can be used to write and edit the program. After that save the Application in a file with the name HelloWorldApp.java
How to compile this program?
The Java compiler (javac) converts a Java Application into Java byte code. Now open the DOS shell and move to the directory where you have saved Java Program. Then enter the following command to compile.
Javac HelloWorldApp.java
After the successful compilation, Java byte code will be produced which will be automatically stored in the same directory but with file name having extension .class. For the running example, the class filename will be
HelloWorldApp .class
How to run this program?
To execute the Java Application, just type the following command
Java HelloWorldApp
Finally, you will get the output as "Hello java !"