Reputation: 4600
JIT compilers are used to convert java byte-code into native machine language. And as far as I know, there is no program which can directly convert java byte-code into binary file such as .exe files. So why JIT compilers can't be used to produce binary from the byte-code?
Upvotes: 4
Views: 1100
Reputation: 3155
IBM Java Runtime is capable of storing the results of dynamic bytecode to native code compilation in its shared data cache and sharing it between JVMs (prooflink).
Upvotes: 0
Reputation: 3110
The aims of JITs and compilers are normally different, I think that is the main reason.
That said, the Maxine VM contains a JIT written in Java that is used to compile the entire VM itself and the output is written to a so-called bootimage, essentially being a binary. However, even this binary needs an executable, called loader, to start.
So, there is at least one example for a JIT that is used to produce a binary, but normally, the aims of a JIT do simply not include producing a binary.
Upvotes: 1
Reputation: 440
Jit is a re compiler, so for any particular system platform, it compiles the bytecode into the particular system code. So we cannot directly use the Jit to turn Java-byte code into binary executables.
When the jit produces binary code, its binary format will not support another platform. The main usage of a Jit-compiler is fast compilation as a second compiler for Java. Therefore Jit can't produce binaries from Java bytecode.
Upvotes: 0
Reputation: 2121
JIT = Just In Time. An *.exe is compiled way before of execution. </nitpick>
;)
As others said, there is more to a JVM than just compiling bytecode to native machine code. However, these parts of a JVM can be put into a native library ("dll").
There is at least one project to generate native binaries out of java code: GCJ (http://en.wikipedia.org/wiki/Gcj). I don't know how good it is and whether there is a windows version available. There might also be other Java-to-native compilers out there.
Upvotes: 2
Reputation: 533462
The JIT compiler, compiles the code dynamically.
A static compiler cannot do these things.
Upvotes: 5