summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-29 05:23:41 +0100
committerSven Gothel <[email protected]>2011-11-29 05:23:41 +0100
commitc6091024864e0fc9069683534370306838eb371a (patch)
treee37610645d56defa9efe911f9a96ca0c42aeb987 /src/java/com/jogamp/common/util
parent04391a3f417e10e1b6dafbd8becc63659af633c3 (diff)
JarUtil (Fix Bug 522): Handle case where given URL doesn't contain any '/' (eg. Eclipse 'rsrc:' case)
- Use ':' as 'path' delimiter in case no path via '/' is given. +++ Manual tested w/ Eclipse: Preparations: =============== 1) Set up a vanilla eclipse (3.7.0) workspace 2) Add the JOGL User Library: - Window.Preference - Java.Build_Path.User_Libraries: + JOGL + gluegen-rt.jar + jogl.all.jar + gluegen-rt-natives-linux-amd64.jar + jogl-all-natives-linux-amd64.jar You may add all other native JARs here. Note that these are not required in the CLASSPATH by JOGL, however, they are required by Eclipse to export your project as a Runnable JAR File. 3) New test project - Right-click your project in the Package Explorer and click "Properties". - Select "Java Build Path" and click the "Libraries" tab. + JOGL - Add some simple code .. - Run as Java Application .. Test-1: ========= Export - Right-click your project in the Package Explorer and click "Export" - Select Java.Runnable_JAR_file + Launch configuration + some destination path + Library handling: Copy required libraries into a sub-folder next to the generated JAR Result: Works! ./lala01.jar ./lala01_lib/jogl.all.jar ./lala01_lib/jogl-all-natives-linux-amd64.jar ./lala01_lib/... etc .. Test-2: ========= Export - Right-click your project in the Package Explorer and click "Export" - Select Java.Runnable_JAR_file + Launch configuration + some destination path + Library handling: Package required libraries into generated JAR Result: Works! ./lala02.jar: Manifest-Version: 1.0 Rsrc-Class-Path: ./ gluegen-rt-natives-linux-amd64.jar gluegen-rt.jar jogl-all-natives-linux-amd64.jar jogl.all.jar Class-Path: . Rsrc-Main-Class: Test01 Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/JarUtil.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java
index 517ac1a..4beda94 100644
--- a/src/java/com/jogamp/common/util/JarUtil.java
+++ b/src/java/com/jogamp/common/util/JarUtil.java
@@ -208,13 +208,19 @@ public class JarUtil {
System.out.println("getURLDirname "+aURL+", extForm: "+urlS);
}
// from
- // file:/some/path/gluegen-rt.jar
+ // file:/some/path/gluegen-rt.jar _or_ rsrc:gluegen-rt.jar
// to
- // file:/some/path/
+ // file:/some/path/ _or_ rsrc:
int idx = urlS.lastIndexOf('/');
- if (0 <= idx) {
- urlS = urlS.substring(0, idx+1); // exclude jar name, include terminal '/'
- }
+ if(0 > idx) {
+ // no abs-path, check for protocol terminator ':'
+ idx = urlS.lastIndexOf(':');
+ if(0 > idx) {
+ throw new IllegalArgumentException("URL does not contain protocol terminator ':', in <"+aURL.toExternalForm()+">, got <"+urlS+">");
+ }
+ }
+ urlS = urlS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':'
+
if(DEBUG) {
System.out.println("getJarURLDirname res: "+urlS);
}