-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load keytool utility main class dynamically, trying both the old and …
…new (java 8) class names
- Loading branch information
Showing
4 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.archive.util; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* Wrapper for "keytool" utility main class. Loads class dynamically, trying | ||
* both the old java and new class names. | ||
* @see http://kris-sigur.blogspot.com/2014/10/heritrix-java-8-and-sunsecuritytoolskey.html | ||
*/ | ||
public class KeyTool { | ||
public static void main(String[] args) { | ||
try { | ||
Class<?> cl; | ||
try { | ||
// java 6 and 7 | ||
cl = ClassLoader.getSystemClassLoader().loadClass("sun.security.tools.Keytool"); | ||
} catch (ClassNotFoundException e) { | ||
// java 8 | ||
cl = ClassLoader.getSystemClassLoader().loadClass("sun.security.tools.keytool.Main"); | ||
} | ||
Method main = cl.getMethod("main", new String[0].getClass()); | ||
main.invoke(null, (Object) args); | ||
} catch (Exception e) { | ||
if (e instanceof RuntimeException) { | ||
throw (RuntimeException) e; | ||
} else { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
} |
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
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
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