01-09-2012, 04:43 PM
JAVA LAB MANUAL
Java-Manual.pdf (Size: 742.01 KB / Downloads: 66)
Introduction to JAVA
Java Programming Language:
Java is a very popular and widely used programming language and it was not be an exaggeration to say it is the most widely used programming language in industry now. The reason for its wide popularity was probably the well thought of goals of the programming language. Among other attractive features, the following stand out in ensuring it gets wide acceptability.
The JAVA Virtual Machine:
Contrary to other popular languages, JAVA follows a half-compiled, half-interpreted approach to achieve the famed platform independence. Java inventors also defined a platform independent java machine language called Byte-Code into which java Compiler compiles all Java Programs. This byte code is the machine language of the Java Virtual Machine and is platform independent. Java Virtual Machine is a software interpreter which interprets byte code (.class files) and executes them on the target machine on which the byte code in running. Java inventors provided reference implementations of Java Virtual machine on some of the most popular machine architectures and encouraged vendors in developing the same for almost all machine architectures by providing the reference implementation.
Since the byte code is machine independent, JAVA programs can be compiled once (into byte code) and executed on any machine architecture provided there is a JVM implementation on that architecture.
Java Application Programming Interface:
Java comes with a pretty exhaustive application programming interface which covers a wide ranging set of tasks which programmers need. By providing a easy to use application programming interface, JAVA makes the task of the programmer some what easy, allowing him to focus on the solution to his problem not having to worry about implementing simple data structures, working on lower level file interaction, etc. Java API has classes that provide support for large number of GUI widgets, Input & Output Streams, Database interaction, Socket communication libraries, utility data structures, simple data types, reflection API among other things. The API also is designed with extensibility and provides scope for alternate implementations by a thoughtful separation of Interfaces and implementations.
Installation:
The latest version of JAVA (1.6 at the time of writing this revision of manual) is freely downloadable from www.java.sun.com. All machines in our Java lab have JAVA 1.5 or higher installed at C:\Program Files\Java.
On the Linux/Solaris side, the students should run the command “which javac” on their shell to figure out the path of Java installation.
Java Compiler:
Java Compiler is the utility that compiles Java programs to their corresponding Byte Code(.class files). Javac is platform independent, for the simple reason that both source(input) and output of the javac program are platform independent. Java Compiler or “javac” as it is commonly called would be available in C:\Program Files\Java\jdk1.5.0_01\bin.
Java Interpreter:
Java interpreter or the Java Virtual Machine (It is called so because interpreter is a machine emulator executing each instruction in byte-code, line by line) is the software which executes Byte-Code. The interpreter is machine dependent because it interprets machine independent byte-code on a given machine architecture. The Java interpreter or “java” as it is commonly called would be available in C:\Program Files\Java\jdk1.5.0_01\bin