JOGL Opengl WriteCloneable in eclipse - java

I am following this tutorial.
Although I did exactly same as the tutorial, even i watched the video.
Even i tried other tutorial.But all of my try, i got that error everytime.
When i click to run, a error box display and "A Java Exception has occurred."
And i see that errors in consol
Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/common/type/WriteCloneable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
...
Even i uninstalled jdk&jre and i download last version and install.
I am using eclipse, Windows 7 home premium 64 bit.

At first, his tutorials contain several errors, I already complained in the comments of his Youtube video. I advise you to use the official tutorials in our wiki and to contact us on the official forum if you need some help.
Something was probably wrong in your environment or you used the 32 bits version with a 64 bits JVM. If you don't know which JARs you should use for the native libraries, just take the both and let GlueGen pick the right one.

Make sure you add all the 4 libs in your project, like this.
-lib
--gluegen-rt.jar
--gluegen-rt-natives-windows-amd64.jar
--jogl-all.jar
--jogl-all-natives-windows-amd64.jar
That works to me:)

Looks like a problem with your classpath since the WriteCloneable class isn't being found - one or more of the jars that you need is probably missing from the build path.
In Eclipse: Right click on your project / Properties / Java Build Path / Libraries tab. Check that the JOGL libraries that you need are all there.

Had the same problem. I solved it by adding the dependencies for gluegen. First I only had:
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>
this solved the problem:
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>

I find solution.
If you get JVMUtil or WriteCloneable error with NoClassDefFoundError, you must copy that 4 library jar to java/jre/lib/ext folder.
thanks for schabby.

Related

java.lang.NoClassDefFoundError when trying to instantiate class from jar

I did found quite a lot about this error, but somehow none of the suggested solutions resolved the problem.
I am trying to use JNA bindings for libgphoto2 under Ubuntu in Eclipse (moderate experience with Java on Eclipse, none whatsoever on Ubuntu, I'm afraid). The bindings in question I want to use are here:
http://angryelectron.com/projects/libgphoto2-jna/
I followed the steps described on that page, and made a simple test client that failed with the above error. So I reduced the test client until the only thing I tried to do was to instantiate a GPhoto2 object, which still produced the error. The test client looks like this:
import com.angryelectron.gphoto2.*;
public class test_class
{
public static void main(String[] args)
{
GPhoto2 cam = new GPhoto2();
}
}
The errors I get take up considerably more space:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Structure
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test_class.main(test_class.java:12)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Structure
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
libgphoto2 itself is installed, it runs from the command line, I even have the development headers and am able to call GPhoto2 functions from python, so the problem can't be located there.
When looking at the .class files in Eclipse, however, they didn't have any definitions. So I figured that might be the problem, especially since there was an error when building the whole thing with ant (although the .jar was succesfully exported, from what I could make out the error concerned only the generation of documentation).
So I loaded the source into eclipse and built the .jar myself. At this occasion Eclipse stated there were warnings during the build (though no errors), but didn't show me the actual warnings. If anyone could tell me where the hell the build log went, that might already help something. I searched for it everywhere without success, and if I click on "details" in eclipse it merely tells me where the warnings occured, not what they were.
Be that as it may, a warning isn't necessarily devastating, so I imported the resulting Jar into the above client. I checked the .class files, this time they contained all the code. But I still get the exact same list of errors (yes, I have made very sure that the old library was removed from the classpath and the new ones added. I repeated the process several times, just in case).
Since I don't have experience with building jars, I made a small helloworld jar, just to see if I could call that from another program or if I'd be getting similar errors. It worked without a hitch. I even tried to reproduce the problem deliberately by exporting it with various options, but it still worked. I tried re-exporting the library I actully need with the settings that had worked during my experiment, but they still wouldn't run. I'm pretty much stuck by now. Any hints that help me resolve the problem would be greatly appreciated.
In addition to what #Paul Whelan has said. You might have better luck by just get the missing jar directly.
Get the missing library here, set the classpath and then re-run the application again and see whether it will run fine or not.
What version of java are you using com/sun/jna/Structure may only work with certain JVMs.
In general, packages such as sun., that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun. packages are not 100% Pure Java.
More details here
Your jar needs a MANIFEST.MF which tells your application where the library is found. Create the file in you project root-directory in eclipse and add the following lines:
Manifest-Version: 1.0
Class-Path: <PATH_TO_LIB__CAN_BE_RELATIVE>.jar // e.g Class-Path: ../test.jar
<empty line>
Right-click your project in eclipse, go to Export->next->next->next->Use existing manifest from workspace, select it and click on finish. This should work.
Another solution is to compile the classes into the jar itself with Maven.

How to identify the dependent libraries I need

I am building a little something in Java that uses Wolfram|Alpha to come up with integrals. I downloaded the Wolfram API and it comes with a sample program that you can use to figure stuff out. Here's that at GitHub.
There's a portion in the comments that says:
* To compile or run this program you will need the following dependent
* libraries on your classpath (including WolframAlpha.jar, of course):
*
* commons-codec-1.3.jar
* httpclient-4.0.1.jar
* httpcore-4.0.1.jar
* commons-logging.jar
... and I have no idea how to do this. I'm using this project as a way to learn Java, so I am skipping a bunch of sleep-inducing fundamentals.
Are these libraries available in the vanilla Java install, or do I have to go fetch them from elsewhere? I want to avoid loading up my system with redundant stuff.
When I try to run the script without loading these libraries it ends in an error, predictably. Here's the error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SocketFactory
at com.wolfram.alpha.net.HttpProviderFactory.getDefaultHttpProvider(HttpProviderFactory.java:18)
at com.wolfram.alpha.WAEngine.<init>(WAEngine.java:36)
at simpleSample.main(simpleSample.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.scheme.SocketFactory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
I am using Eclipse as my IDE. I don't think it matters here, but it might.
#dimplex has already answered. These are releases of several Apache projects. Next time you meet these problems, try:
Google:
Like:
Google commons-codec-1.3.jar
Google httpclient-4.0.1.jar
Google httpcore-4.0.1.jar
Google commons-logging.jar
The first result for EVERY search above is a couple clicks away from the download you're looking for.
Maven Central Search:
http://search.maven.org
(I'm not copying every link, just search for the Jar file names.)
This one is even more direct, but I'd recommend the Google way, as you can get a glimpse of the project page.
You have to upgrade the httpclient.jar to version 4.1.
As you can see in the javadoc theses class available from this version
These are all (old) Apache Software Foundation libraries. The download locations are as follows:
commons-codec-1.3.jar
httpclient-4.0.1.jar
commons-logging.jar
httpcore-4.0.1.jar

Installing Zest 2 from GEF4

I need to move to Zest 2 from GEF4. I got Zest2 from the Eclipse market place. However when I run a program that utilizes it, I get the following error
Caused by: java.lang.ClassNotFoundException: org.eclipse.gef4.geometry.planar.Rectangle
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
I'm assuming this means that I need the GEF4 Geometry pack as well so I try to download that from gef4 - http://download.eclipse.org/tools/gef/gef4/updates/integration
However that isn't allowed since it says I am missing package javafx.collections.
Cannot complete the install because one or more required items could not be found.
Software being installed: GEF4 Geometry JavaFX Conversion 0.1.0.201407251903 (org.eclipse.gef4.geometry.convert.fx.feature.group 0.1.0.201407251903)
Missing requirement: GEF4 Geometry JavaFX Conversions 0.1.0.201407251903 (org.eclipse.gef4.geometry.convert.fx 0.1.0.201407251903) requires 'package javafx.collections [2.0.0,3.0.0)' but it could not be found
Cannot satisfy dependency:
From: GEF4 Geometry JavaFX Conversion 0.1.0.201407251903 (org.eclipse.gef4.geometry.convert.fx.feature.group 0.1.0.201407251903)
To: org.eclipse.gef4.geometry.convert.fx [0.1.0.201407251903]
Can someone please advise me on how I can fix this? Thanks.
I believe the GEF4 zest plugins are broken at the moment. The framework is still under development and things got broken/changed from time to time.
I also received the JAVAFX issue during update about 2 weeks ago. Today I updated again and the issue is gone. However, when I run some application based on recent zest 2 code, I am getting the same class not found error for classes in org.eclipse.gef4.geometry.planar package.
It seems many packages in geometry plugin are marked as "export only to ..." option and the allowed downstream plugin list is empty.
The problem you have reported is related to missing JavaFX dependencies. These are contributed by e(fx)clipse, so this has to be included in your target. You can refer to the GEF contributor guide at http://wiki.eclipse.org/GEF/Contributor_Guide to get guidance on how to set up your workspace (and target) to work with GEF4. The guide also describes our policy with respect to limited exposing of (provisional API) packages.
In general, let me add that we are currently rewriting Zest2 based on GEF4 MVC.FX, using JavaFX for visualization. That is, the org.eclipse.gef4.zest.core, org.eclipse.gef4.zest.jface, and org.eclipse .gef4.zest.ui bundles are deprecated and will be removed in the Mars timeframe. You can find details here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=372365.

How to use xstream fro xml serialization in eclipse

I am having some trouble figuring out how to download and use xstream in eclipse. When I download the binary distribution from the website, I get a zip file. Where should I extract it, and how do I use it?
Edit:
OK, I have added it to my build path, but now when I try to use XStream to serialize an ArrayList<Earmark> where Earmark is a class that I have defined, I get the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at com.thoughtworks.xstream.XStream.<init>(XStream.java:334)
at examples.TestEarmarkExtractor.SerializeEarmarks(TestEarmarkExtractor.java:19)
at examples.TestEarmarkExtractor.main(TestEarmarkExtractor.java:48)
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
Update: The error is occurring before I try the serialization. It occurs on the line
XStream xs = new XStream();
Extract the zip file to a directory (e.g. C:\Program Files\XStream)
In eclipse, right-click on your project and select Build Path > Configure Build Path...
Select Libraries tab
Select Add External Jars..
Navigate to the lib folder of your XStream download and select the jar(s) to be added
Select Open
Select OK
And here's the Two Minute Tutorial on how to use XStream.
Got this exception, then I download kxml2-min-2.3.0.jar and add it as a library and now it works (using xstream 1.4.4.jar)
You need to unzip the .zip file to get at the .jar file, which you put on your classpath for your project in eclipse (Google if you don't know how to add third party library .jars to your project classpath in Eclipse).
Once it is added to your project's classpath, you use the classes contained within it as you would any other classes, and the documentation on the XStream website tells you how to use them.
Good choice by the way, XStream is great!
You can add this library:
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>
I had added the two libraries: dom4j-2.0.0-ALPHA-2.jar and xstream-1.4.7.jar and the same issue were displayed. After adding the kxml2-min-2.3.0.jar the issue is not happening.

Getting a weird ClassNotDefFoundException on runtime with GWT

I am deploying a web application based on GWT. When I compile, I don't get any errors, but in runtime, I get this one (not complete stack trace):
java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at org.gvsig.remoteClient.sos.SOSClient.<init>(SOSClient.java:47)
at com.uji.project.server.ConnectServiceImpl.makeConnection(ConnectServiceImpl.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by:
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
I have read on this website that that is probably caused if one or more classes are not available on running time but, as seen, the error is caused by some problem with the XML parser, but I have the XML parser included in my lib folder. In detail, in the project's lib folder, it is possible to find 3 JAR files: gwt-maps.jar, gwt-servlet.jar, and kxml2.jar*.
If I open "kxml2.jar" file I can see folder org that within has xmlpull folder, that within has v1 folder and finally XmlPullParserException.class.
So...why on runtime do I not have this class available if it is included on the lib folder?
In appengine classes can only access to the classesof the JRE which are in this whitelist. If this jar is using another class of the JRE it won't be included in runtime.
Here you can read that "XML processing APIs including DOM, SAX, and XSLT" are compatible with appengine. Maybe xmlpullparser is not compatible, but I'm not sure.
Finally a colleague told me the solution to this runtime error! :D
When a GWT application is deployed, many files are copied under a small file structure (pending from ) that contains all classes, libraries and other files that are needed on runtime.
For some reason, if you don't tell on purpose Eclipse to copy (on compile/deploy time) a specific library into that PATH, the application will not find on runtime that library and will raise an error.
Solution (for me) was as simple as copying by hand that library into that folder: In my case was copying "kxml2.jar" under "C:\gwt-2.1.0\SOSProject\war\WEB-INF\lib". I restarted the application and just worked. :D
I hope this patch/solution will help others to solve this annoying problem under GWT!
Try this
Window->Preferences->Java Build Path->Add Jars
Navigate to your project/lib, select kxml2.jar Hit OK.
In the end, what I did was to start again from the beginning: In the same workspace I had different projects and maybe there were, let's say, interferences between them.
So, I unzipped again the GWT SDK, start a new project, copied the original source code on the new project, deployed it and on runtime, now I am not getting that weird ClassNotDefFound error. Now I am getting another one, but that is another issue! Thanks to all.

Categories