Platform-independent means that the code (bytecode) compiled by java can run on all operating systems. The program is written in a human-readable language. It may contain words, phrases, etc. that the machine cannot understand. For the source code that the machine can understand, it needs to use a language that the machine can understand, usually a machine-level language. Therefore, the role of the compiler has come. The compiler converts the high-level language (human language) into a format that the machine can understand. Therefore, a compiler is a program that translates the source code of another program from a programming language into executable code. This executable code may be a series of machine instructions that can be directly executed by the CPU, or it may be an intermediate representation interpreted by a virtual machine. This intermediate representation in Java is Java bytecode.
Step by step Execution of Java Program:
In the case of C or C++ (language that isn't platform independent), the compiler generates a .exe file that is OS-dependent. once we attempt to run this .exe file on another OS it doesn't run, since it's OS-dependent and hence isn't compatible with the opposite OS.
Java is platform-independent but JVM is platform dependent
In Java, the most point here is that the JVM depends on the OS – so if you're running Mac OS X you'll have a special JVM than if you're running Windows or another OS. These facts are often verified by trying to download the JVM for your particular machine – when trying to download it, you'll tend an inventory of JVMs like different operating systems, and you'll obviously pick whichever JVM is targeted for the OS that you simply are running. So we will conclude that JVM is platform-dependent and it's the rationale why Java is in a position to become “Platform Independent”.
Important Points:
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.