Java is said to be platform independent because of its byte code which runs on any os only by class file without source code?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Java is said to be platform independent because of its byte code which runs on any os only by class file without source code??

I made some changes knowingly in a class file of a java program but when I recompile it and ran it it gave me an error which meant that source file is verified with class file then how come program can run in Ubuntu Linux only with class file if it needs to be verify the class file and source file of a program?? its like how a developers give it's software to user without giving it's source code????

8th Jul 2019, 4:40 PM
Aditya
3 Answers
+ 2
If it is open source, you can find the source code, probably in the developer's website. If it is propreitary, you can't access it
9th Jul 2019, 2:25 AM
Da2
Da2 - avatar
+ 1
Well the byte code is basically the compiled version of your program which JVM (Java Virtual Machine) can execute. The fact that it's the JVM of the particular OS which changes the byte code to machine code, makes Java portable. Also, note that if an OS doesn't yet have a version of JVM installed (or created) on it, the byte code won't run.
9th Jul 2019, 3:10 PM
Uday Narayan Mukherjee
Uday Narayan Mukherjee - avatar
0
Thank u that makes some sense 👍👍👍
9th Jul 2019, 4:02 PM
Aditya