Reputation: 6765
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();
Upvotes: 4
Views: 13737
Reputation: 11
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.
Upvotes: 1
Reputation: 2095
You can add this library:
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>
Upvotes: 2
Reputation: 2491
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)
Upvotes: 3
Reputation: 44250
C:\Program Files\XStream
)Build Path > Configure Build Path...
Libraries
tabAdd External Jars..
lib
folder of your XStream download and select the jar(s) to be addedOpen
OK
And here's the Two Minute Tutorial on how to use XStream.
Upvotes: 6
Reputation: 29867
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!
Upvotes: 2