Results 1 to 11 of 11

Thread: jvm

  1. #1
    Join Date
    Sep 2010
    Posts
    18
    Rep Power
    0

    Default jvm

    if java is considered to be "platform independent", why is the interperter in jvm written in C??

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Because java is platform independent, not the java interpreter. Besides, if the interpreter were written in java how would you run it?

    The concept is this. The VM is a native app, but behaves the same way on each platform (its supposed to anyway). The code that is actually run by the VM is the same all over. It has no knowledge of the platform its running on, it is abstracted from hardware by the VM.

    Also, just because something is written in C doesn't mean it ISN'T cross platform. A pure C app that doesn't use native libraries can run on any platform that has the same architecture (CISC vs PPC).

    Java code is truly portable in the sense that as long as your platform has an interpreter (JVM), you can run java code. The same cannot be said for most C, C++, ObjC, etc apps because they link to native libraries to perform operations making them platform and architecture dependent. Java has no architecture dependencies.

  3. #3
    Join Date
    Sep 2010
    Posts
    18
    Rep Power
    0

    Default

    so a jvm interpreter can nvr be written in java?? if no, why not?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I don't know that there is anything in the JVM specification (again as far as I know) that specifies what it can or can't be written in. If the JVM is running on a Java machine (and I've heard that these have existed in the past), then I imagine that the JVM could be written in Java. For all practical purposes though, for 99.999% of machines that run on Windows, Unix, Mac and other OS's, then there's no way that a 100% Java application can communicate fully with the OS.

  5. #5
    Join Date
    Sep 2010
    Posts
    18
    Rep Power
    0

    Default

    thnx a lot :)

  6. #6
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    But also, if the jvm was written in java, and there was not another non java jvm running on the host, the how would the jvm even execute? a jvm is required to execute java statements, so a java jvm would require another jvm to run on top of. Java the language is completely virtual existing only in the context of the virtual machine it runs in, it cannot be executed directly by hardware as it is not machine code but byte code. The jvm is the interface between java and hardware, so if it was written in java itself, what would serve as it's interface?

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    @quad: yep you're right of course. In my misguided post, if a chip implemented the JVM, there would be no need for a JVM in software.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,767
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    I don't know that there is anything in the JVM specification (again as far as I know) that specifies what it can or can't be written in. If the JVM is running on a Java machine (and I've heard that these have existed in the past), then I imagine that the JVM could be written in Java. For all practical purposes though, for 99.999% of machines that run on Windows, Unix, Mac and other OS's, then there's no way that a 100% Java application can communicate fully with the OS.
    There was even a Java Operating System, tastefully abbreviated as JOS (ahem ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Remember Project looking glass? But both of those ran on a Hypervisor - which acted as the JVM. Just like BluRay.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JosAH View Post
    There was even a Java Operating System, tastefully abbreviated as JOS (ahem ;-)

    Well then it's no wonder that it's now obsolete. ;)

  11. #11
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Take a look at some of the Project Looking Glass videos online if you get the chance. It was a cool concept! (though, perhaps, totally impractical). I don't have a machine old enough to boot the liveCD anymore, otherwise it'd be fun to play with!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •