Maybe this is only a follow-up bug, but i keep on getting an error when trying to start a jar which is using jogl. I tried to use the described library-technique from http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE with eclipse. Resource strings without directory path lead to crash: For example: IOUtil.getClassURL->jar:rsrc:gluegen.jar!/com/jogamp/common/util/cache/TempJarCa che.class getJarURL->jar:rsrc:gluegen.jar!/ getJarURLDirname fails on this URL at final URL jarUrlRoot = JarUtil.getJarURLDirname in Platform.loadGlueGenRTImpl Exception in thread "main" java.lang.ExceptionInInitializerError at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:1155) at demos.jgears.JGears.<clinit>(JGears.java:47) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa der.java:56) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.substring(Unknown Source) at com.jogamp.common.util.JarUtil.getJarURLDirname(JarUtil.java:114) at com.jogamp.common.os.Platform$3.run(Platform.java:305) at java.security.AccessController.doPrivileged(Native Method) at com.jogamp.common.os.Platform.loadGlueGenRTImpl(Platform.java:299) at com.jogamp.common.os.Platform.<clinit>(Platform.java:208) ... 5 more
Changing the directory of the jogl jar in the deployed jar is a workaround here. The bug only occurs if the jogl and gluegen jars are in the root of the deployed jar. This is the default for the eclipse jar export when using a library.
Created attachment 293 [details] Modified JarUtil.java which does not show the problem (not clean) The are several problems in the old JarUtil class. On the one hand and empty directory in the URL leads to an String-Error. The other problem is that the URL could have another protocol, e.g. if one uses onejar, then the protocol would look different, at the moment it is hard-coded length and it is not even checked if the first chars are what expected. The attached file is not a clean fix but a proposal in which direction to change.
Hi Peter, I have troubles to reproduce your case. Here is what I have done: 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) 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 .. 4) 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: ./lala01.jar ./lala01_lib/jogl.all.jar ./lala01_lib/jogl-all-natives-linux-amd64.jar ./lala01_lib/... etc .. The libs are all in the resulting classpath (of the JAR's MANIFEST), well .. it doesn't hurt. Obviously you are referring to a different process, please elaborate.
Adding Wade to validate my trial @ comment 3
Ok .. it's a jar in a jar (at root) .. I add a test case for this and use your ideas to better the JarUtil class.
(to Sven, regarding comment #3) Let me know when (or if) I need to validate something here still. When exporting a JAR from Eclipse, usually people either choose to put the library JARs inside the exported JAR, or to unpack the library JARs inside the exported JAR, so hopefully either case will work with JOGL. The one you chose (unpack in a directory beside the JAR) is not as common, though we should still support it. I guess people like their exported JARs to be self-contained :)
JarUtil: Improve Robustness (Bug 522) and API doc, prepare for Jar-In-Jar. Add unit test. http://jogamp.org/git/?p=gluegen.git;a=commit;h=04391a3f417e10e1b6dafbd8becc63659af633c3 JarUtil (Fix Bug 522): Handle case where given URL doesn't contain any '/' (eg. Eclipse 'rsrc:' case) http://jogamp.org/git/?p=gluegen.git;a=commit;h=c6091024864e0fc9069683534370306838eb371a 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