compiler or an interpreter?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    compiler or an interpreter?

    Hi,
    Is JVM a compiler or an interpreter?


    -Thanks & Regards,
    Hamsa
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by gaya3
    Hi,
    Is JVM a compiler or an interpreter?


    -Thanks & Regards,
    Hamsa
    JVM (Java Virtual Machine), it is the JRE, required for the running of Java programs, which includes a Java interpreter.

    Have you ever use javac.exe?

    sukatoa.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      There is a JVM specification that might be of interest to read.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by gaya3
        Hi,
        Is JVM a compiler or an interpreter?


        -Thanks & Regards,
        Hamsa
        The JVM used to be just an interpreter and in a lot of implementations just
        'green' threads were implemented (they blocked when an OS call blocked).
        After a lot of complaints had come in about the lack of speed Sun came up
        with 'hotspot' compilation which is JIT (Just In Time) compilation plus a watch-
        dog that determined *what* code to compile and when in order to speed up
        the execution of the virtual machine code.

        Nowadays the JVM even preloads a lot of core classes (compiled to machine
        code) such as String, Number, Integer etc. There still is an interpreter on board
        but the hotspot mechanism is so 'aggressive' nowadays that most (if not all)
        of the code is compiled to actual machine code before it could run in interpreted
        mode.

        So the JVM is a bit of both but it became more of a compiler nowadays. Note that
        it doesn't compile a high level human readable language (that's the job for javac)
        but it translates virtual machine code (the Java byte code) to native machine code.

        kind regards,

        Jos

        Comment

        Working...