summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2012-11-09 10:55:41 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2012-11-09 10:55:41 +0100
commit99fc9f0eb315d56d2dd80467537c521f3bf44d52 (patch)
tree0151439cfa83beae41d19462e0340c91d1085379 /trunk
parentf57cc1d56b24f255904303906331a7b3e614fc2d (diff)
downloadpdf-over-99fc9f0eb315d56d2dd80467537c521f3bf44d52.tar.gz
pdf-over-99fc9f0eb315d56d2dd80467537c521f3bf44d52.tar.bz2
pdf-over-99fc9f0eb315d56d2dd80467537c521f3bf44d52.zip
Don't rely on being executed from app dir
Diffstat (limited to 'trunk')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
index f966bb71..f93c7b5c 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
@@ -42,12 +42,12 @@ public class SWTLoader {
*/
public static void loadSWT() throws InitializationException {
try {
- log.debug("loading " + getSwtJarName());
URLClassLoader cl = (URLClassLoader)SWTLoader.class.getClassLoader();
Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
addUrlMethod.setAccessible(true);
- String swtLibPath = "lib-swt/" + getSwtJarName();
+ String swtLibPath = getSwtJarPath() + getSwtJarName();
+ log.debug("loading " + swtLibPath);
File swtLib = new File(swtLibPath);
if (!swtLib.isFile())
throw new SWTLoadFailedException("Library " + swtLibPath + " not found");
@@ -79,6 +79,14 @@ public class SWTLoader {
return "swt-" + os + "-" + getArchBits() + ".jar";
}
+ private static String getSwtJarPath() {
+ String path = SWTLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath();
+ int idx = path.lastIndexOf('/');
+ idx = path.lastIndexOf('/', idx - 1);
+ path = path.substring(0, idx + 1);
+ return path + "lib-swt/";
+ }
+
private static class SWTLoadFailedException extends Exception {
private static final long serialVersionUID = 1L;
@@ -86,4 +94,5 @@ public class SWTLoader {
super(msg);
}
}
+
}