What is Java?
Java, a high-level programming language, is developed by Sun Microsystems. Originally, it was designed to develop programs for set-top boxes and handheld devices. Though, later it became a popular programming language for creating web applications. Java is intended to let application developers “write once, run anywhere” (WORA), which means compiled Java code can run on any platforms that support Java without the need of recompilation.
The syntax of Java is similar to C++. And the difference is, Java is strictly an object-oriented programming language. The Java programs have classes, which are used to define objects and methods. These objects and methods are assigned to individual classes. In Java, variables and functions have to be explicitly defined, which makes it more strict than C++. As a result, Java source code may produce errors or exceptions more easily than other languages but this also makes the limitation of other types of errors which can be caused by unassigned types or undefined variables.
Java programs are interpreted by the Java Virtual Machine (JVM) and do not run directly by the Operating system, unlike Windows executables (.EXE files) or Macintosh applications (.APP files). The Java Virtual Machine or JVM runs on multiple platforms which make all Java programs as multiplatform. Java programs can run on different platforms, like Macintosh, Windows, and Unix computers. But JVM should be installed in different platforms to run Java applications or applets at all. The JVM is a part of the Java Runtime Environment (JRE), which makes it available for free download.
Features of Java:
- Compiled and interpreted: Java compiler translates the source code into bytecode and then machine code is produced by the interpreter which can be directly executed by the machine.
- Platform independent: A program is said to be platform independent if it can run on all available operating systems. Any modification in the operating systems, system resources and processor could not affect the java programs. It means that the bytecode generated by a java compiler could be employed on any machine having any operating system.
- Object Oriented: Java is purely object-oriented language as in java everything is an Object. As Java is based on the Object model, it can be easily extended.
- Secure: Java is developed to be secure in a networked environment. A bytecode verification process is used in Java run time environment to ensure that code loaded over the network does not violate Java security constraints. It secures from the threat of virus and misuse of resources. The security feature of Java helps to develop virus-free, tamper-free systems. In Java, authentication techniques are based on public-key encryption.
- Robust: Java is a robust Programming Language that can handle Run-time Error, has automatic garbage collection and does not have pointer concept and Exception Handling. Java eliminates certain types of programming errors. As being strongly typed programming language, which allows Java extensive compile-time error checking. And it does not support memory pointers, which reduces the possibility of overwriting memory and corrupting data. The memory leaks are eliminated by garbage collection which is done by automatic memory management. Various other problems associated with dynamic memory allocation and de-allocation are also eliminated.
- Architecture neutral: Architectural neutral means the programming language can run on any available processors in the real world without considering the development and compilation of processor. Any system that implements the Java Virtual Machine can interpret Java applications that are compiled to bytecodes. The Java applications can run on most of the platform as Java Virtual Machine is supported across most operating systems. An architecture-neutral object file format is created using Java compiler that makes the compiled code executable on many processors, in the presence of Java runtime system.
- Portable: The languages which support platform independent and architectural neutral feature are known as portable. The architecture-neutral and having no implementation dependent makes Java portable. Some languages like C, C++, Pascal are considered non-portable language whereas Java is a portable language. Java has the compiler which is written in ANSI C of a POSIX subset with a clean portability boundary.
- Distributed: Java can be used to create distributed applications. Distributed applications in Java are created using RMI and EJB. The multiple client systems depend on multiple server systems in the distributed application, so if any problem arises in one server system, it will not be reflected on any client system. Java also enables the development of applications on the network and both data and program can be shared. Remote objects can be accessed using Java through the internet and allow programmers to work from different remote locations.
- Multithreaded and interactive: The multithreaded feature available in Java makes possible to write programs which can perform many tasks simultaneously. And the interactive feature allows the developers to construct different interactive applications that can run smoothly.
- Dynamic and Extensible: The Dynamic memory allocation feature reduces the wastage of memory and improves the performance of the application. At the runtime, the process of allocating the memory space to the input of the program is known as dynamic memory allocation. To allocate memory space dynamically we use an operator called ‘new’ operator which is also known as dynamic memory allocation operator. Java programs have an extensive amount of run-time information which are used to verify and check accesses to objects at run-time.
- Networked: Java mainly used for desktop and mobile based applications whereas J2EE, a Java programming language based computing platform, is used for developing network-based applications.
- Ease of development: The reusability of codes in Java make the development of programs easier.
- Scalability and Performance: The use of Just-In-Time compilers in Java enables high performance. And also by enhancing the start-up time and minimizing the consumption of memory in a Java runtime environment, we can improve the scalability and performance of Java programs.
- Client-side scripting language as well as server side: Initially in the previous version, it was only client-side scripting language which needed a browser to execute the code, and didn’t use to involve server interaction. But the newer versions and frameworks also support server-side scripting. Still, mostly, it is used as a client-side scripting language.
After Sun microsystem and Netscape collaborated to compete with Microsoft, they decided to use the wave of hype surrounding Java at that time. Netscape Communications had decided that the scripting language they wanted to create would complement Java and should have a similar syntax, which excluded adopting other languages such as Perl, Python, TCL, or Scheme.