ZipException / classpath problem with jocl trying to run HelloJOCL

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

ZipException / classpath problem with jocl trying to run HelloJOCL

nyholku
I'm trying to run this code in Eclipse:

http://jogamp.org/wiki/index.php/JOCL_Tutorial

I've set up my class path like this:

http://www.sparetimelabs.com/temp/jocl-classpath.png

when I run the code I get:

Catched ZipException: error in opening zip file, while addNativeJarLibsImpl(classFromJavaJar class com.jogamp.common.os.Platform, classJarURI jar:file:/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/gluegen.jar!/com/jogamp/common/os/Platform.class, nativeJarBaseName gluegen-natives-macosx-universal.jar): [ file:/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/gluegen.jar -> file:/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/ ] + gluegen-natives-macosx-universal.jar -> slim: jar:file:/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/gluegen-natives-macosx-universal.jar!/
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.jogamp.common.os.Platform
        at com.jogamp.common.util.VersionUtil.getPlatformInfo(VersionUtil.java:55)
        at com.jogamp.opencl.util.JOCLVersion.getAllVersions(JOCLVersion.java:78)
        at com.jogamp.opencl.CLPlatform.initialize(CLPlatform.java:171)
        at com.jogamp.opencl.CLPlatform.initialize(CLPlatform.java:142)
        at com.jogamp.opencl.CLPlatform.getDefault(CLPlatform.java:184)
        at com.jogamp.opencl.CLContext.create(CLContext.java:171)
        at com.jogamp.opencl.CLContext.create(CLContext.java:146)
        at HelloJOCL.main(HelloJOCL.java:28)

and I can't figure out what I'm doing wrong.

An almost identical project/build path setup in Eclipse works for me with jogl.

br Kusti





java -jar jocl.jar:gluegen-rt.jar -Djava.library.path="path/to/jocl/libs:path/to/gluegen-rt/libs" com.jogamp.opencl.util.CLInfo
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

gouessej
Administrator
This post was updated on .
Hi

You shouldn't set the Java library path, it isn't required in your case as the JARs containing native libraries are in the same directory than the JARs containing Java libraries.

Moreover, why do you use "-jar"? You should use "-cp" or "-classpath". Please read the "man" (about -jar):
http://www.manpagez.com/man/1/java/
other user class path settings are ignored
Please follow our instructions:
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#Compile_and_run_your_project_from_the_command_line

Edit.: Please ensure you haven't put any JogAmp JARs into the JVM and that you haven't installed JOGL as an extension.

Edit.2: It should work:
java -classpath "/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/gluegen-rt.jar:/Users/nyholku/JoclTests/jogamp-all-platforms-v2.1.1/jar/jocl.jar:." com.jogamp.opencl.util.CLInfo

Replace the "." by the directory containing your .class file.

Edit.3: Under Eclipse, don't forget the "exported" flag:
http://svn.code.sf.net/p/tuer/code/pre_beta/.classpath
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

nyholku
Hi Julien,

thanks for answering and pointing to the wiki page I had not found.

However meanwhile something I read from somewhere solved the problem. I had gluegen.jar in my Eclipse project Libraries definitions and for some reason that messed things up. Removing it makes the program run.

Interestingly in my other project that works I do have gluegen.jar and it still works. Confusing...maybe order of libraries or something. I need to investigate this further.

As to your comment about the  'why - jar and not -classpath', I'm not using neither as I'm on Eclipse. The last line of my post was an accidental copy paste from you wiki:

http://jogamp.org/wiki/index.php/JOCL_FAQ#Getting_Started

which I incidentally think is not quite correct. Apart from the -jar/-cp issue it also tells you that JWS based test can be run to test for proper installation. In my experience it is next to impossible to for mortals to get JWS work on latest Mac OS X  with all the Oracle / Apple messing of the Java scene going on :( JWS seems to be, if not dead, then buried alive in Mac.
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

nyholku
Test because of posting problems...
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

gouessej
Administrator
In reply to this post by nyholku
gluegen != gluegen-rt

The JOCL wiki needs to be fixed a bit  but you didn't exactly follow the command line mentioned in the wiki anyway, it mentions (just below this command line) that you have to extract the libraries from the JARs to use it as is.

It's possible to use Java Webstart under Mac, I mentioned it somewhere, I'm looking for the things to modify in the setup...
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

nyholku
Yes, like I said I was not trying to use command line at all so I did not bother to extract the libraries and I was not going to paste that line in my post. Just an accident.

As to JWS, great if you can make it work, I can't run run anybody's JWS applications atm, not my own, yours or my banks!

Anyway, just re-tested and if I put  gluegen.jar (which is not necessary to include at all as like you pointed out gluegen != gluegen-rt )  topmost in the Export/Order list in the Eclipse build path, then the I get the ZipException but I put it last then it works. My fault of course in every respect but nasty little bugger to find.

Thanks for your help.

br Kusti
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

gouessej
Administrator
In reply to this post by nyholku
nyholku wrote
In my experience it is next to impossible to for mortals to get JWS work on latest Mac OS X  with all the Oracle / Apple messing of the Java scene going on :( JWS seems to be, if not dead, then buried alive in Mac.
Java Webstart works under latest Mac OS X with those tricks:
http://hub.jmonkeyengine.org/forum/topic/jogl-support-jogl2-that-is/page/10/#post-166487
http://hub.jmonkeyengine.org/forum/topic/jogl-support-jogl2-that-is/page/11/#post-166499

Edit: I'm sorry to say that but people aren't forced to use Apple products. Java Webstart is easier to use under GNU Linux (OpenJDK + Icedtea-web installed by default most of the time).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

nyholku
Thanks for the links.

So you are sorry that people are not forced to buy Apple? Me too ;)

cheers Kusti
Reply | Threaded
Open this post in threaded view
|

Re: ZipException / classpath problem with jocl trying to run HelloJOCL

gouessej
Administrator
You're welcome. I hope that it works but the typical end users won't do that.

Supporting OS X requires a bigger effort than other platforms and it's becoming less and less Java friendly.
Julien Gouesse | Personal blog | Website