summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:19:33 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:19:33 +0000
commit0dd186ac6277292cd8af7555952a67abeda9ec92 (patch)
tree51984e7c8b588eebd84a89f3579df3e9c6b2ed00 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils
parentf3f167b6590dda0812c4bf316ce203f73769e06c (diff)
downloadpdf-over-0dd186ac6277292cd8af7555952a67abeda9ec92.tar.gz
pdf-over-0dd186ac6277292cd8af7555952a67abeda9ec92.tar.bz2
pdf-over-0dd186ac6277292cd8af7555952a67abeda9ec92.zip
Don't rely on being executed from app dir
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@257 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
index f966bb71..f93c7b5c 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java
+++ b/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);
}
}
+
}