title: How exactly does the Java interpreter or any interpreter work?
body: <p>I have been figuring out the exact working of an interpreter, have googled around and have come up with some conclusion, just wanted it to be rectified by someone who can give me a better understanding of the working of interpreter.</p>
  
  <p>So what i have understood is:</p>
  
  <ol>
  <li>An interpreter is a software program that converts code from high level 
  language to machine format.</li>
  <li>speaking specifically about java interpreter, it gets code in binary format 
  (which is earlier translated by java compiler from source code to bytecode).</li>
  <li>now platform for a java interpreter is the JVM, in which it runs, so 
  basically it is going to produce code which can be run by JVM.</li>
  <li>so it takes the bytecode produces  intermediate code and the target machine 
  code and gives it to JVM.</li>
  <li>JVM in turns executes that code on the OS platform in which JVM is 
  implemented or being run.</li>
  </ol>
  
  <p>Now i am still not clear with the sub process that happens in between i.e.</p>
  
  <ol>
  <li>interpreter produces intermediate code.</li>
  <li>interpreted code is then optimized.</li>
  <li>then target code is generated</li>
  <li>and finally executed.</li>
  </ol>
  
  <p>Some more questions:</p>
  
  <ul>
  <li>so is the interpreter alone responsible for generating target code ? and 
  executing it ?</li>
  <li>and does executing means it gets executed in JVM or in the underlying OS ?</li>
  </ul>