Introduction to Java Programming Language
Java is an Object Oriented Language that was designed to meet the need for a platform independent language. Java is used to develop applications that can run on a single computer as well as on a distributed network. Java is a language that can be used to develop stand-alone and internet-based applications. A Java application works everywhere, from the smallest devices, such as remote controls and microwave ovens to supercomputers. One good thing about Java programs is that they are independent of the type of computer, telephone, television or operating system these devices run on. Java programs work on any type of compatible devices that support Java.
Need for Java
Java language contains built-in support for the World Wide Web (www), which is a service on the internet to retrieve information’s in the form of web pages. The primary motive behind developing Java language was the need for a portable and platform-independent language that could be used to produce code that would run on a variety of Control Processing Unit (CPU) under different environments.
Most programming languages are platform dependent. Applications developed using these languages can run only on those types of hardware and software platforms on which the applications are compiled. Compilation of an application refers to conversion of the program instructions, written in a programming language to the language that the computer understands.
Java is a platform independent language that enables you to compile an application on one platform and execute it on any platform. This saves your effort to write and compile the same application for different platforms. Java can be used to develop internet-based application that can be accessed by programmers working on various types of computers.
Characteristics of Java
Like we discoursed above, Java can be used to develop web-based applications that can be accessed from any part of the world. Java applications can also be accessed using any kind of operating system, such as Windows, Linux or Solaris. Java also provides a run time environment, which implements various security checks on Java applets and does not allow them to perform any malicious task. In general, Java has the following characteristics:
- Java is Simple
A Java programmer does not need to know the internal details of Java as to how memory is allocated to data because in Java, the programmer does not need to handle memory manipulation. Java is a simple language that can be learned easily even if you have just started programming. Java was designed to be easy for the programmer to learn and use effectively. The Syntax for various Java statements is easy to understand.
- Java can be compiled and interpreted
Java programs are first compiled and then interpreted. While compiling, the compiler software checks for the errors in the program and lists all the errors on the screen. After you have made the program error free and have recompiled it, the compiler converts the program into computer language.
- Java is Object-Oriented
Java is an object oriented programming language. It supports various features of OOP, such as abstraction, encapsulation, polymorphism and inheritance. To implement the object oriented language, the entire code of the program must be written within a class.
- Java is Portable
Portability enables a program to run on any platform without changing the source code of the program. The program developed on one computer can run on another computer which might have a different platform. Java enables the creation of cross-platform programs by compiling the programs into an intermediate representation called Java Bytecode. Bytecode is the result of compiling a Java program. You can execute this code on any platform.
Converting a Java program into Bytecode makes a Java program portable because any computer installed with the JVM for the platform on which it is running can interpret the Bytecode. The JVM is the interpreter of the bytecode, which reads the bytecode line by line and executes it.
- Java is Distributed
Java applications can be distributed among various computers on the network. Java is designed for the distributed environment of the internet because it supports the various Internet protocols, such as Transmission Control Protocols and Internet Protocol (TCP/IP). Java applications can open and access remote objects on the internet in the same manner as they can open and access objects in a local network. Java contains a package, Remote Method Invocation (java.rmi), which is used to build, distributed and client-server based applications.
- Java is Secure
Java has built-in security features that verify that the programs do not perform any destructive task, such as accessing the files on a remote system. Java does not allow the use of explicit pointers, which are used to refer to the memory locations in a C++ program. All references to the memory are symbolic references, which means that the programs cannot access memory locations without proper authorization.
When you access a program over the internet, it is susceptible to attacks from virus programs. In Java, the compiled Bytecode is strongly type checked. Any changes made in the Bytecode are flagged as errors and the program does not execute. This ensures the security of the Java program over the internet.