NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
SearchEngine27
Joined: 21 Jun 2012 Posts: 66
|
Posted: Thu Jul 12, 2012 9:21 pm Post subject: java.lang.NoClassDefFoundError - external library copied and trimmed in dist/lib |
|
|
I'm building a jar file that has several external dependencies and I want to package them all up into one jar, because eventually I will be serving them up via Java WebStart, and I want to make it just one file that is transferred. So, in the project build.xml, I put in the following:
| Code: |
...
<target name="-post-jar">
<jar jarfile="${dist.jar}" update="true">
<zipfileset src="${dist.jar}" includes="**/*.class" />
<zipgroupfileset dir="dist/lib" includes="*.jar" excludes=""/>
<manifest>
<attribute name="Main-Class" value="LucentZUI.DocumentViewer"/>
</manifest>
</jar>
</target>
...
|
and that does exactly what its supposed to. The problem I encountered was when I try to run the jar without NetBeans. I get a NoClassDefFoundError thrown, which didn't seem right. So I examined the jar file that was created, and sure enough its not there. But the problem wasn't with my logic, the problem was that in the dist/lib folder, there is a smaller version of the original jar.
The original jar file has all the required classes, but when NetBeans copies it into the dist/lib folder, it doesn't take all the classes in the jar.
Why does this happen? How can I fix it? and why don't I run into problems with this when I run the jar from the ide (since it is still missing the classes)?
Thanks. |
|
| Back to top |
|
 |
SearchEngine27
Joined: 21 Jun 2012 Posts: 66
|
Posted: Fri Jul 13, 2012 2:37 pm Post subject: |
|
|
So I figured it out. I was under the impression that the build-impl.xml file specified some odd library copying for ant, but it was actually library conflicts.
I was using ICEPdf, and Batik, and ICEPdf uses Batik libraries as well, but they use older versions so when Netbeans built my project, somehow it did it in a way that was OK, but when I took the libraries and placed them all into the same jar, somehow that screwed it up. I still don't fully understand how I would not get the same exception while running from netbeans though. As I said, the classes were still missing |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|