Why can I execute JAR directly from bash?

I am a longtime Java guy and know that the way to run the JAR with the main class specified in the file MANIFEST.MFin the Jar is simple:

java -jar theJar.jar

I used this to start the Fabric3 server (contained bin/server.jarin its standard distribution). I noticed that when I unpacked it from the tarball distribution, it was marked as executable. On a whim I tried

./server.jar

from the command line bash( bashversion 4.1.5 in Ubuntu 10.10), and now, the server started, as if I typed the usual command java -jar .... The JAR is structured like a regular JAR; I did headon it, and there was no command in the first bytes #!, so bashI should not worry to start the Java virtual machine with it, right? Or did this version have bashthe ability to run JARs correctly with the correct manifest? The requested minds want to know ...

+5
source share
2 answers

bash. linux ( ), binfmt_misc, , . , , , linux , .

+12

bash, - , binfmt_misc. ( , Java)

+2

All Articles