library not included in the jar file when exported

I'm using the eclipse platform and trying to export my program into a jar file. However a library I'm using pdfbox is not getting included. I am able to run the file program just fine when I'm in the Eclipse. But when I run the jar file I'm getting class not found. Help? Thanks

My setting in Java Build Path do include the PDFbox library .

C:\Documents and Settings\Yan Li\Desktop>java -jar test.jar

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/pdfbox/pdmodel/PDDocument

at cdr.parser.Generic_Parser.<init>(Generic_Parser.java:59)

at cdr.parser.Controller.<init>(Controller.java:9)

at cdr.parser.GUI$OpenAction.actionPerformed(GUI.java:78)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown

Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Message was edited by:

d1sturbanc3

[2592 byte] By [d1sturbanc3a] at [2007-11-27 3:53:43]
# 1
I don't know how eclipse does jars, but you could always try manually creating the jar:jar cmf Manifest.txt test.jar MyFiles
Nethera at 2007-7-12 8:57:47 > top of Java-index,Java Essentials,New To Java...
# 2

I don't seem to have jar available in my command line. What is the package I have to download to make the jar tool available?

These are my files:

05/09/2007 06:00 PM<DIR> .

05/09/2007 06:00 PM<DIR> ..

05/09/2007 06:00 PM 4,297 Controller.class

05/09/2007 05:19 PM 5,375 Controller.java

05/09/2007 06:00 PM 8,817 Generic_Parser.class

05/09/2007 05:20 PM21,529 Generic_Parser.java

05/09/2007 06:00 PM497 GUI$1.class

05/09/2007 06:00 PM 2,625 GUI$OpenAction.class

05/09/2007 06:00 PM 2,763 GUI$OpenLabelAction.class

05/09/2007 06:00 PM981 GUI$ParseAction.class

05/09/2007 06:00 PM 7,573 GUI.class

05/09/2007 05:12 PM13,760 GUI.java

and the build paths which the library files FontBox-0.1.0 and PDFBox-0.7.3 are located in my c:\eclipse\plugin\ directory.

Message was edited by:

d1sturbanc3

d1sturbanc3a at 2007-7-12 8:57:47 > top of Java-index,Java Essentials,New To Java...
# 3
the command for jar is located in your jdkC:/.../JDK/bin/jar
Nethera at 2007-7-12 8:57:47 > top of Java-index,Java Essentials,New To Java...
# 4

You can't package jars within jars. Well, you can, but the runtime won't load classes from the inner jars unless you specifcally write or otherwise obtain a third-party classloader that does it for you. It's not generally a good idea anyway, we normally strive for more modularity than that. Consider, for example, how you would apply a fix to this pdfbox. You'd have to re-package and re-deploy the entire application, rather than just give instructions for people to obtain the new dependency.

If you really want to do it, though, there's an Eclipse plugin called [url=http://fjep.sourceforge.net/]FatJar[/url] that gives you a wizard to do it, and will also generate an Ant script to do repeat it

edit: and feed me dukes, dammit! I'm fed up with this crappy star

Message was edited by:

georgemc

georgemca at 2007-7-12 8:57:47 > top of Java-index,Java Essentials,New To Java...
# 5

So you are saying I should include the source to the pdfbox? How would I develop my app that uses the pdfbox? I created a seperate package. Are you saying that I should develop my program in pdfbox's package?

I mean there has to be a way I can fix this dependency problem.... I can include the pdfbox in my "installation" process. How do I fix this dependency issue?

What is the best way there a way to get my package into an executable with my program? I have 2 binary library which I need to include.... PDFbox and PDFfonts. Is there a way to get it into an .exe format with eclipse. I assume there is a plugin for ecplise to do it. Any recommendations?

I have couple of java files and 2 binary library in this project.

Thanks!

Message was edited by:

d1sturbanc3

Message was edited by:

d1sturbanc3

d1sturbanc3a at 2007-7-12 8:57:47 > top of Java-index,Java Essentials,New To Java...