4 ms·
Java JAR files are similar, but reversed. You can add anything you want to the beginning of the JAR file (or is it any ZIP file?) so long as it doesn't include
by mbreese 3y ago
Java JAR files are similar, but reversed. You can add anything you want to the beginning of the JAR file (or is it any ZIP file?) so long as it doesn't include the Zip file header "PK". So, I use this to prepend a bash script that ultimately calls
java -jar $0
It makes it very easy to setup and use Java based command line programs on a server.
- zmmmmm 3y agothis sounds incredibly useful but I couldn't get it to work. I just get java.util.zip.ZipException: invalid CEN header (bad signature) at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1623) if I try to do anything with a JAR file that has leading text. I'm creating it just using echo 'java -jar $0' | cat - test.jar > test.run.jar Is there more to it?
- SeanA208 3y agohttps://github.com/puniverse/capsule/blob/master/capsule-util/src/main/resources/capsule/execheader.sh https://github.com/puniverse/capsule/blob/master/capsule-uti... This is what the (now defunkt) Capsule project prepends to get this same effect
- nneonneo 3y agoTechnically, you should update the offset to the central directory in the Zip footer, along with the offsets to each file header in each central directory entry. If you don’t, the zip file reader has to apply some heuristics to locate the central directory; not all readers implement these heuristics, and those that do won’t always be robust. The “unzip” utility can be useful as a sanity check; run “unzip -t” to test the integrity of the file.
- mbreese 3y agoDid you add a shebang line? I have a small bash stub that I use. It’s roughly (I also add JAVA_OPTS, etc…): #!/bin/bash java -jar $0 Then… cat stub.sh myproject.jar > myexec See: https://github.com/compgen-io/ngsutilsj/blob/master/src/scripts/stub.sh https://github.com/compgen-io/ngsutilsj/blob/master/src/scri...