Introduction to Java
- What is java ? It is a programming language and platform for application development.
- It was first introduced by Sun Microsystem in 1995 and later obtained by Oracle Corporation.
- Nowadays, Java has mostly used programming language.
About Java Platform
- It is a collection of programs that helps the user to develop and run applications that are written in Java programming language.
- It includes an execution engine, a compiler, and a set of libraries. Java is a platform-independent language.
- Java is not particular to any processor or operating system.
Introduction to PC?
- A personal computer is an electronic device capable of performing computations.
- As we know, it comprises of a monitor, keyboard, mouse, and memory to store information.
- The essential component of the personal computer is a “PROCESSOR.”
What is an Assembly Language?
- The computer is an electronic device. Electronic signals or binary signals can perceive it.
- For example, the 4-volt electronic signal may represent binary number 1, while 0 volts may represent binary number 0.
- Your PC will run continuously for these signals.
- It is known as 8-bit computing.
- Nowadays, the processor is capable of decoding 64-bit time.
- However, the question arises that what is the relation of this concept with the programming language JAVA?
- To understand this with an example.
- Let’s add two numbers (3+1), which are categorized by some binary numbers (1100011), so how are we going to tell the computer?
- Correct, we are going to use assembly language to get our code executed.
- Now, we give the command to a computer in the format, as shown below.
- Our code to add three numbers in this language would be in this order:
- Let’s Store number 1 at memory location say A
- Let’s Store number 2 at memory location say B
- Let’s Store number 3 at memory location say C
- Add contents of Location A, B & C
- Store results
- The computer will read this code and execute the program.
- This would be a long process then until ASSEMBLER comes into action.
Introduction to Assembler and Compiler?
- It is a program that converts the assembly language into machine language.
- You can directly type your password into PC by using a program.
- It converts machine code (110001…) and sends it to the processor.
- Let’s have an example: Addition of (3+1), the assembler will convert code into machine code and provides the output.
- It is used for programs that translate the source code from a high-level programming language into a machine level language to create an executable program.
The main difference between the Assembler and Compiler is:
- The Compiler takes the source code and then translates it into the assembly code, whereas Assembler acquires the Compiler generated assembly code and then converts it into the machine code.
- As we say in software development languages, the whole assembly code could have diminished into one-line (print f 3+1 A) with the help of a software called COMPILER.
- The Compiler is used to convert your C language code into assembly code, and then the assembler converts it into the machine code, then machine code will be transmitted to the processor.
- The commonly used processor used in PC or Computers is the Intel processor. Following is the diagram of the working of the process:
The way how Java Virtual Machine works?
Java Virtual Machine is working on different processors and O.S.
Here are the following steps which will help us to understand the work of Java Virtual Machine:
- Let’s have a code to display the addition of two numbers i.e., System.out.println(3+1) and save it as .java file.
- By using the java compiler code is converted into an intermediate code known as bytecode. The output is a .class file.
- The Code is unable to understand by any platform until and unless a virtual platform called the Java Virtual Machine is present in the system.
- The Virtual Machine occupies the RAM of your operating system. When Virtual Machine gets this bytecode, it will recognize on which platform it is working on, and then it converts the bytecode into the native machine code.
Now learn about how Java Platform is Independent?
- Java compiler does not produce local executable code for a particular machine.
- As Java is platform-independent because machine-independent code is also called as bytecode.
- Every time Java produces a unique bytecode.
- The bytecode is understandable to any JVM installed on any OS, and so we can say that java source code can run on all operating systems.