Search code examples
javaeclipsejarexportexecutable

creating 100% standalone executable jar that doesn't require the java command


so apparently if you create an executable jar, in order to run it you still need the java command:

java -jar something.jar

but what if I just want it to run without the java command, so just directly from the command line

something.jar 

is there a way to export my java app in eclipse in order to accomplish such


Solution

  • 2024 update

    According to https://en.wikipedia.org/wiki/Excelsior_JET Huawei bought them in 2019 and took the product off the market.

    However, Oracle now has GraalVM which can do something similar. See https://www.graalvm.org/latest/reference-manual/native-image/#build-a-native-executable for an introduction.

    2011 answer

    Excelsior JET - http://www.excelsior-usa.com/jet.html - claims to compile to native code and bring its own runtime support, so it does not require an existing JVM. Commercial product.

    I have not tried it myself, but they have spent quite a bit of effort over the years to market JET as a great deployment method for precompiled binaries.


    Also note that if you have an executable/runnable jar which works fine with "java -jar someting.jar" and you just want to be able to invoke it in a more convenient way, this is the job of the program accepting your command and launching the java command.

    For Linux you can frequently add an alias saying that "something" expands to "java -jar something.jar", and some command interpreters allow for saying that all commands ending with jars should be executed specially. The exact details depend on which shell (command line interpreter) you are using.