Last active
January 4, 2017 13:27
-
-
Save ryankennedy/5691324 to your computer and use it in GitHub Desktop.
Quickly creating a command line utility to run ASMifier (http://asm.ow2.org/asm40/javadoc/user/org/objectweb/asm/util/ASMifier.html).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <errno.h> | |
int main(int argc, char* argv[]) { | |
int i; | |
char* argv2[argc+3]; | |
argv2[0] = "java"; | |
argv2[1] = "-cp"; | |
argv2[2] = argv[0]; | |
argv2[3] = "org.objectweb.asm.util.ASMifier"; | |
for (i = 1;i < argc; i ++) { | |
argv2[i+3] = argv[i]; | |
} | |
argv2[argc+3] = 0; | |
execvp("java", argv2); | |
printf("Cannot execute '"); | |
for (i = 0;i < argc+2; i ++) { printf("%s ", argv2[i]); } | |
printf("', caused by error: %d\n", errno); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stealing from Sam Pullara's idea for creating standalone executables from Java JAR files: | |
http://www.javarants.com/2004/01/07/standalone-java-programs-on-unix-systems-now-with-c-code/ | |
I've modified it slightly to handle a JAR file that doesn't have a Main-Class entry in the manifest. | |
In my case, I'm feeding it the ASM "all" JAR so I can have a command line utility for running the | |
org.objectweb.asm.util.ASMifier utility. | |
gcc asmifier.c | |
cat > asmifier a.out ~/.m2/repository/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar | |
chmod +x asmifier |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment