2

Can we convert Java byte-code to machine code in a Windows that will work without the JVM ? there are many tools that wrap Jar application into an executable like Launch4J but it's always an application that depend to JVM.

3

3 Answers 3

4

As it has been pointed out, GCJ is the way to go:

GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.

They do have a manual to get you started.

Sign up to request clarification or add additional context in comments.

2 Comments

Note that it does not support a recent version of Java and you will still need runtime libraries, so it is of limited practical use.
For all practical purposes, GCJ has been a dead man walking ever since Sun open sourced Java under the same license. Today there is VMkit and some other projects, but they typically don't support Windows.
0

Without a JVM, running Java Programs can be achieved using GraalVM with alleged performance improvements. See https://www.graalvm.org/22.1/reference-manual/native-image/

Comments

0

Another option is using IKVM and .NET6+. IKVM is converting Java to a .NET Application. Under .NET 6+, one can then turn this into a natively compiled application, so .NET does not need to exist on the target Windows system.

Note that performance may suffer, if you go this route.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.