r/java • • Jun 21 '11

Making Really Executable Jars

http://skife.org/java/unix/2011/06/20/really_executable_jars.html
44 Upvotes

12 comments sorted by

View all comments

2

u/skeeto Jun 21 '11 edited Jun 21 '11

You can skip the shell part, though this makes assumptions about the location of java.

$ cat prepend
#!/usr/bin/java -jar

$ cat prepend example.jar > example
$ chmod +x example
$ ./example
Hello, World

My system lets me run jar files directly anyway. I don't know what part of my system is allowing this to work correctly, though.

$ chmod +x example.jar
$ ./example.jar
Hello, World