Why Is Java Portable?

 


Why Is Java Portable?

I mentioned a few times that Java is portable and that Java programs can run on any operating system. It is time to explain how this is possible. Let’s start with a simple drawing, like the one in Figure 1-4.

 Java is what we call a high-level programming language that allows a developer to write programs that are independent of a particular type of computer. High-level languages are easier to read, write, and maintain. But their code must be translated by a compiler or interpreted into machine language (unreadable by humans because is it made up of numbers) to be executed, because that is the only language that computers understand.

In Figure , notice that on top of the operating systems, a JVM is needed to execute a Java program. JVM stands for Java virtual machine, which is an abstract computing machine that enables a computer to run a Java program. It is a platform-independent execution environment that converts Java code into machine language and executes it. 

So, what is the difference between Java and other machine code that is designed to run on a specific microprocessor architecture or operating system


and other high-level languages? Well, other high-level languages compile source code directly stem, such as Windows or UNIX. What JVM does, it that is mimics a Java processor making it possible for a Java program to be interpreted as a sequence of actions or operating system calls on any processor regardless of the operating system.

 And because the Java compiler was mentioned, we have to get back to Java 1.1, which was widely used, even as new versions were released. It came with an improved Abstract Window Toolkit (AWT) graphical API (collections of components used for building applets), inner classes, database connectivity classes (JDBC model), classes for remote calls (RMI), a special compiler for Microsoft platforms named JIT,4 support for internationalization, and Unicode. Also, what made it so widely embraced is that shortly after Java was released, Microsoft licensed it and started creating applications using it. The feedback helped further development of Java, thus Java 1.1 was supported on all browsers of the time, which is why it was so widely deployed.

So, what exactly happens to developer-written Java code until the actual execution? The process is depicted in Figure 
                                                   Figure:- From Java code to machine code



In Figure , you see that Java code is compiled and transformed to bytecode that is then interpreted and executed by the Java virtual machine on the underlying operating system. This is what Java is: a compiled and interpreted general-purpose programming language with a large number of features that make it well suited for the web. 

Post a Comment

0 Comments