In console running a jar file is normally done by java -jar application.jar Is there a way to run jar files by executing ./application.jar? I'd like this behaviour for any jar file. I tried chmod +x application.jar but it won't work as it gives the following error: invalid file (bad magic number): Exec format error. Further, it would be specific to one application.
- 291
1 Answers
.jar file is not executable by itself.. its just a modified(compiled and ziped) text file; the executable is the /usr/bin/java which sits on a path known to the system; that is why you can type java -jar app.jar and it works
./command means this folder in another shell loaded in this one(the command shell);
. command means this folder this shell
http://www.linfo.org/dot_slash.html
you can define an alias for the repetitive part java -jar
temporary
type alias inside a terminal to see already defined aliases
type your presumed alias to see if it returns command not found so you can use it
then type alias command='java -jar' to define the alias
after that you can use it as command app.jar
permanent
edit the .bashrc file from your home folder and add an alias like the one in temporary save and exit and relog
- 451