How do Java applets get loaded

java-applet

I had this conversation yesterday with a friend of mine and I was trying to explain to him that applets are precompiled code that is loaded by the JVM through the Java browser plugin. I am trying to find some documentation or a detailed description of what is going on in the browser when a site with an applet is visited and eventually how it gets loaded, but couldn't.

Could anyone please provide some insight?

Best Answer

Quick answer: Java source code in .java files is compiled to .class files that contain Java byte code. These are packaged into a single .jar file. The web page HTML includes a reference to this jar file. The browser fetches the jar, fires up the locally installed Java Virtual Machine (JVM) and hands it the jar file data. The JVM then does Just-In-Time (JIT) compilation of byte-code to native code as necessary.

Oracle have provided some information on Applet launching.

Related Question