Introduction to Java
Java is a high level, Object-Oriented modern programming language designed in the early 1990s by Sun Microsystems, and currently owned by Oracle.
Java is Platform Independent, which means that you only need to write the program once to be able to run it on a number of different platforms!
Java is portable, robust, and dynamic, with the ability to fit the needs of virtually any type of application.
Features of Java
Apart from being a Platform/System independent language, there are other reasons too for the immense popularity of this language. Some of its features are:
1. Simple: Java is a simple programming language. All, the difficult concepts of C and C++ have been omitted in Java. For example, the concept of pointers-which is very difficult for both learners and programmers has been completely eliminated from Java.
2. Object-Oriented: Java is an object, oriented programming language. This means Java programs use objects and classes. What is an object? An object is anything that really exists in the world and can be distinguished from others. Everything that we see physically will come into this definition, for example, every human being, a book, a tree, and so on.
3. Distributed: Information is distributed on various computers on a network. Using Java, we can write programs, which capture information and distribute it to the clients. This is possible because Java can handle the protocols like TCP/IP and UDP.
4. Robust: Robust means strong. Java programs are strong and they don't crash easily. There are two reasons for this. Firstly, Java has got excellent inbuilt exception handling features. An exception is an error that occurs at run time. If an exception occurs, the program terminates abruptly giving rise to problems like loss of data. Overcoming such problems is called exception handling. This means that even though an exception occurs in a Java program, no harm will happen.
Another reason, why Java is robust lies in its memory management features. User needs not-allocate or deallocate the memory in Java. Everything will be taken care of by JVM only.
5. Secure: Security problems like eavesdropping, tampering, impersonation, and virus threats can be eliminated or minimized by using Java on the Internet.
6. System/Platform Independence: Java's byte code is not machine-dependent. It can be run on any machine with any processor and any operating system.
On compilation, Java program is compiled into bytecode. This bytecode is platform-independent and can be run on any machine, plus this bytecode format also provides security. Any machine with Java Runtime Environment can run Java Programs.
7. Portability: If a program yields the same result on every machine, then that program is called portable. Java programs are portable. This is the result of Java's System independence nature.
8. Interpreted: Java programs are compiled to generate the byte code. This byte code can be downloaded and interpreted by the interpreter in JVM. If we take any other language, only an interpreter or a compiler is used to execute the programs. But in Java, we use both compiler and interpreter for the execution.
9. Architectural Neutral: Compiler generates bytecodes, which have nothing to do with particular computer architecture, hence a Java program is easy to interpret on any machine.
10. High Performance: The-problem with the interpreter inside the JVM is that it is slow. Because of this, Java programs used to run slow. To overcome this problem, along with the interpreter, JavaSoft people have introduced the JIT (Just In Time) compiler, which enhances the speed of execution. So now in JVM, both interpreter and JIT compiler work together to run the program.
11. Multithreaded: A thread represents an individual process to execute a group of statements. JVM uses several threads to execute different blocks of code. Creating multiple threads is called 'multithreaded'.
Java multithreading feature makes it possible to write a program that can do many tasks simultaneously. The benefit of multithreading is that it utilizes the same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along.
12. Scalability: Java platform can be implemented on a wide range of computers with varying levels of resources from embedded devices to mainframe computers. This is possible because Java is compact and platform-independent.
13. Dynamic: Before the development of Java, the only static text used to be displayed in the browser. But when James Gosling demonstrated an animated atomic molecule where the rays are moving and stretching, the viewers were dumbstruck. This animation was done using an applet program, which are dynamically interacting programs on the Internet.
How Java Code Executes
The execution of a Java application code involves three main steps:
1. Creating the Program:
Java programs are written using a text editor or an Integrated Development Environment (IDE) like IntelliJ IDEA, Eclipse, or NetBeans. The source code is saved with a .java extension.
2. Compiling the Program:
The Java compiler (javac) converts the source code into bytecode, which is stored in a .class file. This bytecode is platform-independent and can be executed on any machine with a JVM.

How Java Code Executes
3. Running the Program:
The JVM executes the compiled bytecode, translating it into machine code specific to the operating system and hardware.
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Before learning Java, one must be familiar with these common terms of Java.
- Writing a program is done by a java programmer like you and me.
- The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes the Java program as input and generates bytecode as output.
- In the Running phase of a program, JVM executes the bytecode generated by the compiler.
Java Development Kit (JDK): The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed in Java development.
No comments:
Post a Comment