Platform-independent means that java compiled code (bytecode) 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:
For C or C++ (non-platform independent languages), the compiler generates an .exe file that depends on the operating system. When we try to run this .exe file on another operating system, it will not run because it depends on the operating system and therefore is not compatible with other operating systems.
Java is platform-independent but JVM is platform dependent
In Java, the point here is that the JVM depends on the operating system-so if you are running Mac OS X, you will have a different JVM than running Windows or other operating systems. This fact can be verified by trying to download a JVM for your specific machine-when you try to download it, you will get a list of JVMs corresponding to different operating systems, and you will obviously choose the JVM for the operating system you are running. So we can conclude that JVM is platform dependent, which is why Java can 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.