Created
January 6, 2013 12:23
-
-
Save martiner/4466801 to your computer and use it in GitHub Desktop.
Class load dependency
This file contains hidden or 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
public class Depend { | |
public Depend() { | |
System.out.println("Hello World!"); | |
} | |
} |
This file contains hidden or 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
import java.util.Scanner; | |
public class Main { | |
public static void main(String... args) throws Exception { | |
try { | |
Class.forName("FOO").newInstance(); | |
} catch (Exception ignore) {} | |
System.out.print("Delete the target directory then hit ENTER: "); | |
new Scanner(System.in).nextLine(); | |
Class.forName("Depend").newInstance(); | |
} | |
} |
This file contains hidden or 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
#!/bin/bash | |
TARGET=target | |
MAINJAR=$TARGET/main.jar | |
DEPENDJAR=$TARGET/depend.jar | |
mkdir -p $TARGET | |
javac -d $TARGET src/Main.java src/Depend.java | |
jar cf $MAINJAR -C $TARGET Main.class | |
jar cf $DEPENDJAR -C $TARGET Depend.class | |
java -cp $MAINJAR:$DEPENDJAR Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment