Java is the object-oriented, platform-independent programming language used to develop distributed applications that run on the Internet. It is similar to C++ high-level programming language and architecture-neutral developed by James Gosling, an engineer at Sun Microsystems in 1995 and later acquired by Oracle Corporation. He decided to create a new language since he was not very happy with the C++ programming language used and first named it Oak after the oak tree that he could observe from his office window.
Java was originally called OAK. Java is a computing platform for application development. Object-Oriented meaning the capability to reuse code. Secondly, it is platform-independent, i.e., we don’t have to develop separate applications for different platforms. It is possible to develop a single application that can run on multiple platforms like Windows, UNIX, and Macintosh systems. Java designed for hand-held devices and set-top boxes.
Java technology is both a platform and a programming language. The source codes for Java programs are written in human-readable form in a plain text file with the .java extension, compiled into files with the .class extension using the javac compiler. The program is then executed by the java interpreter using the Java virtual machine (Java VM):
The Java programming system allows the World Wide Web (WWW) to distribute small, interactive application programs — applets. They are hosted on Internet servers, transported to the client over the network, automatically installed, and run locally as part of a document.WWW. The applet has minimal access to the client’s computer resources to provide an arbitrary multimedia interface and perform complex calculations without the risk of damaging data on the disk. Another type of program is Java applications, which are portable code that can run on any computer, regardless of the architecture. The generated virtual code is a set of instructions for execution on the interpreter of the virtual code – the Java virtual machine (JVM - Java Virtual Machine
). Servlets and JSPs (Java Server Pages) have become widespread, allowing clients to access server applications and databases.
The Java language uses the syntax of the C++ language. The main differences from C++ are associated with the need to reduce the size of programs and increase the security requirements for portable applications running on the network. Java does not support pointers (the most dangerous feature of the C++ language) since the ability to work with arbitrary memory addresses through typeless pointers allows you to ignore memory protection. It automatically manages the memory garbage-collection routine activated when the system runs short of memory. Java provides the most secure programming environment. Java doesn’t just fix security loop holes-it eliminates them, which makes Java the perfect language for programming on the Web.
System crackers use programs to forge pointers to memory, steal information from your system, and crash the system permanently. In Java, we can’t forge pointers to memory because there are no pointers.
Java is highly secure because the Java runtime environment provides strict rules for programs started from remote hosts. These programs cannot access the local network, cannot access files on the local system, and cannot start programs.
The system class library of the language contains classes and packages that implement various basic features of the language. The classes included in these libraries are called from the JVM during the interpretation of the Java program. In Java, all program objects are located in dynamic memory (heap) and are accessible through object references, which, in turn, are stored on the stack (stack). This solution eliminated direct memory access but made it more challenging to work with array elements and make it less efficient than C++ programs. It should be noted that Java object references contain information about the class of objects to which they refer, so object references are not pointers but object descriptors. The presence of descriptors allows the JVM to perform type compatibility checks during the code interpretation phase, throwing an exception on error. In Java, the concept of dynamic memory allocation has also been revised: there are no ways to free dynamically allocated memory. Instead, it implements a system for automatically freeing memory (garbage collector) allocated using the new operator.
The desire of developers to simplify Java programs and make them more understandable led to the need to remove header files (.h-files) and to preprocess from the language. Header files in C++ containing class prototypes and distributed separately from the binaries of these classes complicate version control, which allows unauthorized access to private data. In Java programs, the class’s specification and its implementation are always contained in the same file.
Java does not support structures and unions, which are exceptional cases of classes in C++. The Java language does not support operator overloading and typedef overloading, unsigned integers (other than char), or the use of default arguments by methods. There are no multiple inheritances in Java, but there are no destructors (automatic garbage collection is used), the goto operator and the word const are not used. However, they are reserved words of the language.
The most significant new features in Java are interfaces (analogous to abstract C++ classes) and multithreading (the ability to execute parts of code simultaneously).
Changes in J2SE 5.0
Some changes and improvements have been made in the J2SE 5.0 language version:
• introduced the concept of a class template;
• type enumerations are supported;
• simplified information exchange between primitive data types and their classes-shells;
• the definition of a method with a variable number of parameters is allowed;
• static import of constants and methods is possible;
• improved collection formation mechanism;
• added formatted console input / output;
• the number of mathematical methods has been increased;
• introduced new ways to control flows;
• added new features in the kernel, etc.
We’ll be covering the following topics in this tutorial:
What is Java Platform?
Java platform is a computing platform from Oracle that helps to run and develop Java applications. The Java platform consists of an execution engine, a compiler, and a set of libraries. It is platform independent, i.e., we don’t have to develop separate applications for different platforms.
Java can be used to create two types of programs. Those are Applications and Applets. An application is a program that runs on the user’s computers under the operating system. An Applet is a small window based prg.that runs on HTML page using a java enabled web browser like internet Explorer, Netscape Navigator or an Applet Viewer.
Java Features
Here we list the basic features that make Java a powerful and popular programming language
1) Compiled and Interpreter: has both Compiled and Interpreter Feature Program of java is First Compiled and Then it is must to Interpret it .First of all The Program of java is Compiled then after Compilation it creates Bytes Codes rather than Machine Language. Then After Bytes Codes are Converted into the Machine Language is Converted into the Machine Language with the help of the Interpreter. So For Executing the java Program First of all it is necessary to Compile it then it must be Interpreter
2) Platform Independent: Java Language is Platform Independent means program of java is Easily transferable because after Compilation of java program bytes code will be created then we have to just transfer the Code of Byte Code to another Computer This is not necessary for computers having same Operating System in which the code of the java is Created and Executed After Compilation of the Java Program We easily Convert the Program of the java top the another Computer for Executio
3) Object-Oriented: We Know that is purely OOP Language that is all the Code of the java Language is Written into the classes and Objects So For This feature java is Most Popular Language because it also Supports Code Reusability, Maintainability etc.
4) Robust and Secure: The Code of java is Robust andMeans ot first checks the reliability of the code before Execution When We trying to Convert the Higher data type into the Lower Then it Checks the Demotion of the Code the It Will Warns a User to Not to do this So it is called as Robust.
Secure : When We convert the Code from One Machine to Another the First Check the Code either it is Effected by the Virus or not or it Checks the Safety of the Code if code contains the Virus then it will never Executed that code on to the Machine.
5) Distributed: Java is Distributed Language Means because the program of java is compiled onto one machine can be easily transferred to machine and Executes them on another machine because facility of Bytes Codes So java is Specially designed For Internet Users which uses the Remote Computers For Executing their Programs on local machine after transferring the Programs from Remote Computers or either from the internet.
6) Simple Small and Familiar: is a simple Language Because it contains many features of other Languages like c and C++ and Java Removes Complexity because it doesn’t use pointers, Storage Classes and Go to Statements and java Doesn’t support Multiple Inheritance.
7) Multithreaded and Interactive: Java uses Multithreaded Techniques For Execution Means Like in other in Structure Languages Code is Divided into the Small Parts Like These Code of java is divided into the Smaller parts those are Executed by java in Sequence and Timing Manner this is Called as Multithreaded In this Program of java is divided into the Small parts those are Executed by Compiler of java itself Java is Called as Interactive because Code of java Supports Also CUI and Also GUI Programs.
8) Dynamic and Extensible Code: Java has Dynamic and Extensible Code Means With the Help of OOPS java Provides Inheritance and With the Help of Inheritance we Reuse the Code that is Pre-defined and Also uses all the built in Functions of java and Classes.
9) Distributed: Java is a distributed language which means that the program can be design to run on computer networks. Java provides an extensive library of classes for communicating ,using TCP/IP protocols such as HTTP and FTP. This makes creating network connections much easier than in C/C++. You can read and write objects on the remote sites via URL with the same ease that programmers are used to when read and write data from and to a file. This helps the programmers at remote locations to work together on the same project.
10) Secure: Java was designed with security in mind. As Java is intended to be used in networked/distributor environments so it implements several security mechanisms to protect you against malicious code that might try to invade your file system.
For example: The absence of pointers in Java makes it impossible for applications to gain access to memory locations without proper authorization as memory allocation and referencing model is completely opaque to the programmer and controlled entirely by the underlying run-time platform .
11) Architectural Neutral: One of the key feature of Java that makes it different from other programming languages is architectural neutral (or platform independent). This means that the programs written on one platform can run on any other platform without having to rewrite or recompile them.
In other words, it follows ‘Write-once-run-anywhere’ approach. Java programs are compiled into byte-code format which does not depend on any machine architecture but can be easily translated into a specific machine by a Java Virtual Machine (JVM) for that machine. This is a significant advantage when developing applets or applications that are downloaded from the Internet and are needed to run on different systems.
12) Portable: The portability actually comes from architecture-neutrality. In C/C++, source code may run slightly differently on different hardware platforms because of how these platforms implement arithmetic operations. In Java, it has been simplified.
Unlike C/C++, in Java the size of the primitive data types are machine independent. For example, an int in Java is always a 32-bit integer, and float is always a 32-bit IEEE 754 floating point number. These consistencies make Java programs portable among different platforms such as Windows, Unix and Mac .
13) Interpreted: Unlike most of the programming languages which are either complied or interpreted, Java is both complied and interpreted The Java compiler translates a java source file to bytecodes and the Java interpreter executes the translated byte codes directly on the system that implements the Java Virtual Machine. These two steps of compilation and interpretation allow extensive code checking and improved security .
14) High performance: Java programs are complied to portable intermediate form know as bytecodes, rather than to native machine level instructions and JVM executes Java bytecode on. Any machine on which it is installed. This architecture means that Java programs are faster than program or scripts written in purely interpreted languages but slower than C and C++ programs that compiled to native machine languages.
Although in the early releases of Java, the interpretation of by bytecode resulted in slow performance but the advance version of JVM uses the adaptive and Just in time (JIT) compilation technique that improves performance by converting Java bytecodes to native machine instructions on the fly.