Why java is platform independent

  1. Why Java is Platform Independent?
  2. Why Java is platform independent?
  3. How Is The Java Platform Independent?
  4. c++
  5. Why is Java Platform Independent Language?
  6. How is Java platform independent?
  7. Why is Java Platform Independent?


Download: Why java is platform independent
Size: 58.39 MB

Why Java is Platform Independent?

Java is a general-purpose object-oriented programming language similar to C++ but slightly more advanced. One of the core aspects that separates Java from C++ is its platform independence. Java programs can operate on any operating system like Windows, Mac OS, and Linux. Because Java is platform independent it has become an important tool for designing software that can work on multiple platforms without requiring any code changes. What is a Platform Independent? Before we dive into why Java is platform independent, let us first understand what we mean by platform independence. In simple terms, a platform independent program is one that can run on multiple operating systems or hardware architectures without any modifications. For example, a program written in C++ may have to be compiled separately for each operating system it needs to run on. This means that the same code cannot be used for different platforms. Platform independence is, therefore, an important feature for software development as it allows developers to write code that can be used on different platforms without the need for separate versions. Why Java is Platform Independent? In comparison to the C compiler, which creates only natively executable code for a particular machine, the Java compiler produces a unique type of code known as bytecode. When we try to run a Java program on a particular machine, first the program’s source code is passed to a Java compiler, which turns it into intermediate code known a...

Why Java is platform independent?

Here we will Learn Why Java is platform- independent? Asjava converts their code into bytecode with the help of a virtual machine that we call java Virtual Machine or (JVM) so that it can be run on any machine or platform as bytecodes can be understood by each and every machine in this world. Java Virtual Machine Bytecodes are effective platform independence as every machine in this world runs on binary codes or we can say all the machines in this world understands only binary languages and bytecode is easiest and nearest to be converted by binary code to be executed or to understand by machine,. Converting what we care about writing into bytecode makes the machine understand, And in return, the bytecode developed by the machine as of result needs to be converted into programing language or language that a user understands. All these tasks are being done by a virtual machine that we call JVM or Java Virtual Machine. This feature of java standout it among all the other programming languages at that time which was the main publicity of java and most developers are using it as their first choice and being used in almost every gadget from TV remotes to complex software and operating software. To Understand it in a better way we can see how all the programming languages need special treatment on every machine whereas in the case of java, it is the same for every platform so it is widely used globally and developers like to code in java due to its evolution and upgradations in i...

How Is The Java Platform Independent?

Table of Contents • • • • • • • • Introduction Some of the other features of Java are: • Object-Oriented: Everything Java is an object, and concepts like inheritance, polymorphism, encapsulation, etc., can be incorporated into the code. • Secure: Java is secure as it doesn’t have an explicit pointer. Classloader, Bytecode Verifier, and Security Manager also help in improving security. • Robust: The automatic garbage collection in java removes the objects which are not being used by a Java application anymore. It also has strong memory management. • High Performance: It is faster than other traditional interpreted programming languages. • Multithreaded: Many tasks can be dealt with at once using multiple threads, a separate program executing simultaneously. • Distributed: It facilitates users to create distributed applications in Java. • Dynamic: It supports the dynamic loading of classes, i.e., classes are loaded on demand. • Architecture neutral:It has no implementation-dependent features. • Portable: We can carry Java bytecode to any platform. • Platform independent: Java applications can run on any platform. In this blog, we will discuss the platform independence and portability features of Java in depth. Programme Execution in Java Before discussing how Java is platform-independent, we will discuss how a program is executed in Java. The machines cannot understand the code written in Java. So, first, the source code is converted into a machine-understandable form. For t...

c++

Java is operating-system independent because it runs on the Java platform (the JVM): The mantra is "write once, run anywhere" because you write your code using the JDK API, compile that once, and it runs on any operating system that has a JVM available. You write your code, wrap it up in a jar, and that jar runs wherever you want to use it, within reasonable bounds. The job of the JDK and JVM are to abstract away the differences in environments. In contrast, particularly back when Java was created, writing C or C++ for multiple operating systems was a big pain and usually required additional toolkits (of course, the JDK and JVM are a toolkit of sorts), and even today still requires at least recompiling for the target system. There's nothing magic about Java's OS-independence. It would be entirely possible to build the same thing for C or C++: Compile to an intermediary form, provide a runtime that knows how to interpret or recompile that intermediary form for different environments and provide a library that abstracts away environmental differences. Java just...did that, with its own spin on the language. Later, so did the .Net platform. No software is really "independent". Eventually, your program has to call the underlying OS in order to make some basic operations, like allocating memory, create new threads etc. The way to achieve an executable which is "cross platform" is to create specific executable for each OS. Common practice is to write different code for each OS, ...

Why is Java Platform Independent Language?

Since its inception, Java has been incredibly popular among all other programming languages. And the capacity to provide distinctive features is what accounts for the enormous response. Although Java’s syntax is virtually identical to C++’s, it offers many more functionalities. Visit our free technology classes to gain a competitive advantage. Java stood apart from all The way that related methods and variables are bound together in Java objects is similar to how they are in C structures. Additionally, Java offers abstraction, encapsulation, inheritance, and polymorphism, all of which encourage the implementation of objects by the user. Java is widely used in numerous fields, including the creation of Compiling a Code Every time we create code, we adhere to a programming language’s grammar, which is generally readable. A few terms, phrases, variable names, method names, etc. are also included. All of them are regarded as literature that can be read and understood by humans. If full-stack development is of interest to you, enroll in our full-stack development Bootcamp course. As a result, a computer utilizes a compiler to turn source code into machine-readable code, also known as machine-level language. The machine-level code is created by the compiler in a certain format so that the CPU can easily understand it and execute it without error. The way that machine-level languages are The way that machine-level languages are constructed varies depending on the operating system...

How is Java platform independent?

The meaning of Java platform-independent is that the Java compiled code(byte code) can run on all operating systems. A program is written in a language that is a human-readable language. It may contain words, phrases, etc which the machine does not understand. For the source code to be understood by the machine, it needs to be in a language understood by machines, typically a machine-level language. So, here comes the role of a compiler. The compiler converts the high-level language (human language) into a format understood by the machines. Therefore, a compiler is a program that translates the source code for another program from a programming language into executable code. This executable code may be a sequence of machine instructions that can be executed by the CPU directly, or it may be an intermediate representation that is interpreted by a virtual machine. This intermediate representation in Java is the Java Byte Code. Step-by-Step Execution of Java Program • Whenever a program is written in JAVA, the javac compiles it. • The result of the JAVA compiler is the .class file or the bytecode and not the machine’s native code (unlike the C compiler). • The bytecode generated is a non-executable code and needs an interpreter to execute on a machine. This interpreter is the JVM and thus the Bytecode is executed by the JVM. • And finally, the program runs to give the desired output. Execution of Java Program In the case of C or C++ (languages that are not platform independen...

Why is Java Platform Independent?

A programming language is said to be platform independent when a program or application written in it i.e. its source code can run on any operating system or platform, irrespective of where it was developed and compiled. We can define platform as the sum of hardware and software that provides an environment for the program to run. So, what makes Java Platform independent? A program written in any language is in a human readable form. It may contain words, phrases etc which machines do not understand. For any source code to be understood by machines, it needs to be translated to a language understood by machines i.e. machine-level language. This is the job of a compiler, which converts the code written in high level language into a machine level language code. This code is either executed by the CPU directly or it may be an intermediate code that is interpreted by a virtual machine (as in case of Java). This intermediate representation in Java is in the form of Java Byte Code. How Java works? In order to understand its functionality, let us first see the case of C or C++. In case of C or C++, when you create a program and compile it, the compiler generates an .exe file which can only run on the operating system on which it has been created, making it operating system dependent. So, when you try to run it on another operating system, it will not run on it as it is operating system dependent and is not compatible with any other operating system. However, whenever a program is...

JAVA

JVM , JRE , JDK these are all the backbone of java language. Each components work separately . JDK and JRE physically exists but JVM is an abstract machine that means it has not physically exists. JVM JVM (Java Virtual Machine) is a software. It is a specification that provides runtime environment in which java bytecode can be executed. It is not physically exists. JVMs are not same for all hardware and software, for example for windows os JVM is different and for Linux JVM is different. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent. JRE The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK). It contains set of libraries and tools for developing java application. The Java Runtime Environment provides the minimum requirements for executing a Java application. It physically exists. It contains set of libraries + other files that JVM uses at runtime. JDK The Java Development Kit (JDK) is primary components. It physically exists. It is collection of programming tools and JRE, JVM. All 3 are platform dependent. • JVM -> platform dependent. • JRE -> consists of JVM and some other things. Since it include JVM, it is platform dependent. • JDK -> consists of JRE, compiler and some other things. Since it includes JRE which in turn includes JVM, it is platform dependent. The java code before and after compilation is platform independant. You can compile on windows and run the byte code on unix...