JRE is machine dependent but compiler is machine independent

Discussion in 'Java' started by jrefactors@hotmail.com, Dec 10, 2004.

  1. Guest

    When we download JRE, there are different platforms to choose. That
    means JRE is machine dependent, but Java Compiler is machine
    independent.

    Is that the story board?

    Java Code -> Java Compiler -> Class File -> Platform Dependent JRE ->
    Native Code

    Is that correct?
    Please advise. Thanks
    , Dec 10, 2004
    #1
    1. Advertising

  2. Grant Wagner Guest

    <> wrote in message
    news:...
    > When we download JRE, there are different platforms to choose. That
    > means JRE is machine dependent, but Java Compiler is machine
    > independent.


    The compiler itself is machine dependant, that is, you need a different
    Java compiler for each platform you run it on, but the bytecode it
    produces is machine independant (at least in theory). If you include
    things in your Java program that are machine dependant such as
    references to "drive letters" or hardcoding directory path separators
    then the bytecode may be technically machine independant, but it will
    not run correctly on platforms other than the one it is targeted for.

    > Java Code -> Java Compiler -> Class File -> Platform Dependent JRE ->
    > Native Code


    Pretty much. The behaviour of the JRE or JVM (Java Virtual Machine) is a
    "black box", you don't necessarily know (or care) what is going on
    inside. It can "interpret" the bytecode instruction by instruction and
    execute the appropriate native CPU instructions, or it can JIT
    (Just-In-Time) compile the bytecode to native code, then execute that
    native code. Or it can do a bit of both.

    --
    Grant Wagner <>
    Grant Wagner, Dec 10, 2004
    #2
    1. Advertising

  3. Grant Wagner wrote:

    > <> wrote in message
    > news:...
    >
    >>When we download JRE, there are different platforms to choose. That
    >>means JRE is machine dependent, but Java Compiler is machine
    >>independent.

    >
    >
    > The compiler itself is machine dependant, that is, you need a different
    > Java compiler for each platform you run it on,


    No, because the compiler itself (at least Sun's javac) is written in Java,
    so all you need is a (definitely machine dependant) JRE.
    Michael Borgwardt, Dec 10, 2004
    #3
  4. Eric Sosman Guest

    Michael Borgwardt wrote:
    > Grant Wagner wrote:
    >
    >
    >><> wrote in message
    >>news:...
    >>
    >>
    >>>When we download JRE, there are different platforms to choose. That
    >>>means JRE is machine dependent, but Java Compiler is machine
    >>>independent.

    >>
    >>
    >>The compiler itself is machine dependant, that is, you need a different
    >>Java compiler for each platform you run it on,

    >
    >
    > No, because the compiler itself (at least Sun's javac) is written in Java,
    > so all you need is a (definitely machine dependant) JRE.


    You need just a little more, but not much. There's a small
    platform-specific launcher program (about 28KB on Solaris, 45KB
    on Windows) that gets things started. The real "meat" of the
    compiler is, as you say, a bunch of Java bytecode.

    --
    Eric Sosman, Dec 10, 2004
    #4
  5. Eric Sosman wrote:
    >>No, because the compiler itself (at least Sun's javac) is written in Java,
    >>so all you need is a (definitely machine dependant) JRE.

    >
    >
    > You need just a little more, but not much. There's a small
    > platform-specific launcher program (about 28KB on Solaris, 45KB
    > on Windows) that gets things started. The real "meat" of the
    > compiler is, as you say, a bunch of Java bytecode.


    True, but the launcher is actually not necessary and exists only for
    convenience's sake. You could also start the compiler like this:

    java -cp tools.jar com.sun.tools.javac.Main <compiler arguments>
    Michael Borgwardt, Dec 10, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nospawn
    Replies:
    2
    Views:
    501
    Real Gagnon
    Apr 25, 2006
  2. pek
    Replies:
    6
    Views:
    3,674
    Steve W. Jackson
    Jul 6, 2006
  3. Compiler == Machine-independent?

    , Feb 14, 2007, in forum: C Programming
    Replies:
    1
    Views:
    429
    Walter Roberson
    Feb 14, 2007
  4. Prasoon
    Replies:
    1
    Views:
    444
    Andrew Thompson
    Apr 13, 2007
  5. puzzlecracker
    Replies:
    1
    Views:
    507
    James Kanze
    Aug 7, 2008
Loading...

Share This Page