Skip to content

Instantly share code, notes, and snippets.

@briandealwis
Forked from spullara/gist:782523
Created January 17, 2011 13:55
Show Gist options
  • Save briandealwis/782862 to your computer and use it in GitHub Desktop.
Save briandealwis/782862 to your computer and use it in GitHub Desktop.
One-liner to turn jar with Main-Class into executable shell script
# turn a jar with a Main-Class into a stand alone executable
(echo '#!/usr/bin/env java -jar'; cat blahblah.jar) > blah
# turn a jar with a particular main clas into a stand alone executable
(echo '#!/usr/bin/env java -jar package.MainClass'; cat blahblah.jar) > blah
@briandealwis
Copy link
Author

briandealwis commented Aug 17, 2016

Doesn't seem to work any more 😞 Which is strange as jar tf file shows the jar contents.

@rjmunro
Copy link

rjmunro commented Sep 4, 2019

This worked for me, both in mac os and in a linux docker image.

@briandealwis
Copy link
Author

It's working for me too. I really should have included some detail such as the OS and JVM versions that I encountered the problem.

/me blushes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment