This content has been marked as final. Show 10 replies
Can't be done. The best you can do is deploy the 3rd party JARs along with your executable JAR and add them to the manifest Class-Path attribute. But they can't go inside your executable JAR. The class loader won't look for them there.
Ahhh ic, so lets say that I want to put my executable JAR and the external library JAR in the same folder and then run my JAR, how would i set that up? I have been using eclipse to export my program to a JAR and i don't think its doing it right =( Can you give me instructions on how to make the JAR or do you have a link?
Ahhh ic, so lets say that I want to put my executableNot sure what you're asking. You've got 3rd party JARs and your executable JAR in the same directory. Very good. What are you asking me?
JAR and the external library JAR in the same folder
and then run my JAR, how would i set that up?
I haveIt's only doing what you're telling it to do. What does "not right" look like?
been using eclipse to export my program to a JAR and
i don't think its doing it right =(
Does your executable JAR have a manifest? Does it spell out the main class and classpath? If not, make it do so.
>Can you give me
instructions on how to make the JAR or do you have aThe instructions on how to use the jar tool are in the Java tool docs:
Great =) one last thing, will it automatically put the correct entry into the manifest and .classpath? Also how do I tell my JAR to look for the external library in the same directory it was launched from?
Great =) one last thing, will it automatically put"It" being Eclipse? I doubt it. How will it know?
the correct entry into the manifest and .classpath?
Don't depend on anything being done without your knowledge. I think if you create a META-INF directory and put a proper manifest.mf file in it, Eclipse can be told to bundle it up with your JAR. You have to create it.
Also how do I tell my JAR to look for the externalYou can tell it to look in whatever path you wish when you specify the entries to Class-Path.
library in the same directory it was launched from?
Sorry I'm a noob when it comes to making a java program run outside eclipse =P Any good resources you can give me to help with correct classpath entires and manifest file.
The one I gave you is the best. Read the java tool docs. Or Google for "executable jar tutorial" and pick one.
mk =) thanks
Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
I do not get this error when I run and use my program from within the IDE.
The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
I would really like to get this working and I'm very confused XP
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path=""/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="D:/poi.jar"/> <classpathentry kind="output" path=""/> </classpath>
If there is any other code or information that would be helpful in resolving this please let me know and I will post it. I would really like to get my program running on its own.