Use JDK , I can compile a .java file into a .class file, then I can run the .class file, does this mean that the .class file is the final executable file running on JVM ?
Moreover, what’s a jar file ? and the difference between jar file and .class file ?
Use JDK , I can compile a .java file into a .class file, then
Share
1. A class file is a
byte code files, which is executed by the JVM, it has no meaning outside the JVM. Making it meaningful only on JVM but not outside, is what makes every java program run in itsown sandbox .2. Jar file is a collection of all the
class file,librariesnecessary to run the program, consider its an easy way to pack all the files and depending library and providing a single file. We also haveRunnable Jarswhich can be known asExecutable Jar////////// EDITED PART//////////////////
Now this
byte-codeis converted tomachine level executableduring Run-time by theJIT(Just In Time Compiler). JIT will look for the runtime intensive part of the program during Runtime, and then it will convert it into machine level executable, this part of the program is known asHot-spot, and theJITis known asHot-Spot-Compiler.