Skip to content

Commit

Permalink
Handle loading monocle jar from file url
Browse files Browse the repository at this point in the history
  • Loading branch information
hollingsworthd committed Apr 8, 2015
1 parent 13b0413 commit d46ef72
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions browser/src/com/machinepublishers/jbrowserdriver/JavaFx.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.ArrayList;
Expand Down Expand Up @@ -244,10 +245,13 @@ private static URL[] urls() {
}
try {
File monocleTmp = new File(tmpDir, "monocle.jar");
Files.copy(((JarURLConnection) NativePlatformFactory.class.
getProtectionDomain().getCodeSource().getLocation().openConnection())
.getJarFileURL().openStream(),
monocleTmp.toPath());
URLConnection conn = NativePlatformFactory.class.
getProtectionDomain().getCodeSource().getLocation().openConnection();
if (conn instanceof JarURLConnection) {
Files.copy(((JarURLConnection) conn).getJarFileURL().openStream(), monocleTmp.toPath());
} else {
Files.copy(conn.getInputStream(), monocleTmp.toPath());
}
urlList.add(monocleTmp.toURI().toURL());
} catch (Throwable t) {
Logs.exception(t);
Expand Down

0 comments on commit d46ef72

Please sign in to comment.