I'm a longtime Java guy, and know that the way to run a JAR with a main class referenced in a MANIFEST.MF
file within the Jar is easy:
java -jar theJar.jar
I was using this to start up the Fabric3 server (contained in bin/server.jar
in its standard distribution). I noticed that when I unpacked it from the distribution tarball, it was flagged as executable. On a whim, I tried
./server.jar
from my bash
command line (bash
version 4.1.5 in Ubuntu 10.10), and lo and behold, the server started up as if I had typed the normal java -jar ...
command. The JAR is structured like a normal JAR; I did a head
on it, and there was no #!
command in the first few bytes, so bash
shouldn't magically know to start a Java VM with it, right? Or has this version of bash
grown the ability to start JARs with a proper manifest correctly? Inquiring minds want to know...
This may not be a feature of bash at all. If you are running linux (as you have tagged) you may have the binfmt_misc
kernel module, which does a little bit of magic, when you try to execute a program. Basically what this does is it extends the binary formats that linux can execute from just elf to also include some user defined formats, with enough instructions to run them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With