Alas I have searched high and low for a solution to my problem including here and here but to no avail.
So the situation is that I have a folder called bin with all my class files including ImpulseResponseFunction. And in another folder called lib I have all the jar libraries. I have created the following manifest file in the META-INF folder:
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.7.0_51-b00 (Oracle Corporation) Main-Class: ImpulseResponseFunction So I create the jar using:
jar cvfm magicCarbon.jar META-INF/MANIFEST.MF bin/*.class -classpath lib And I get the following output:
-classpath : no such file or directory added manifest adding: bin/ImpulseResponseFunction$1.class(in = 549) (out= 352)(deflated 35%) adding: bin/ImpulseResponseFunction.class(in = 3523) (out= 2057)(deflated 41%) adding: bin/menuBarSepUp$1.class(in = 703) (out= 443)(deflated 36%) adding: bin/menuBarSepUp$2.class(in = 703) (out= 441)(deflated 37%) adding: bin/menuBarSepUp$3.class(in = 900) (out= 556)(deflated 38%) adding: bin/menuBarSepUp.class(in = 1683) (out= 942)(deflated 44%) adding: bin/MyCanvas.class(in = 865) (out= 482)(deflated 44%) adding: bin/openImage.class(in = 635) (out= 433)(deflated 31%) adding: bin/PlotTimeSeries.class(in = 1760) (out= 974)(deflated 44%) adding: bin/WindowSetUp.class(in = 3723) (out= 1952)(deflated 47%) adding: lib/(in = 0) (out= 0)(stored 0%) adding: lib/jfreechart-1.0.19-experimental.jar(in = 13791) (out= 11975)(deflated 13%) adding: lib/jfreechart-1.0.19-src.jar(in = 2009391) (out= 1927691)(deflated 4%) adding: lib/hamcrest-core-1.3.jar(in = 45024) (out= 39918)(deflated 11%) adding: lib/jfreechart-1.0.19-swt.jar(in = 79793) (out= 74024)(deflated 7%) adding: lib/junit-4.11.jar(in = 245039) (out= 215441)(deflated 12%) adding: lib/swtgraphics2d.jar(in = 17492) (out= 16614)(deflated 5%) adding: lib/jfreesvg-2.0.jar(in = 50769) (out= 47864)(deflated 5%) adding: lib/jfreechart-1.0.19.jar(in = 1561720) (out= 1480724)(deflated 5%) adding: lib/orsonpdf-1.6-eval.jar(in = 72444) (out= 67006)(deflated 7%) adding: lib/jcommon-1.0.23.jar(in = 330246) (out= 305996)(deflated 7%) adding: lib/servlet.jar(in = 80054) (out= 70343)(deflated 12%) adding: lib/orsoncharts-1.4-eval-nofx.jar(in = 445025) (out= 412412)(deflated 7%) adding: lib/magicCarbon.jar(in = 4681972) (out= 4682157)(deflated 0%) So first of all what is going on with classpath?
Then when I run using:
java -jar magicCarbon.jar I get:
Exception in thread "main" java.lang.NoClassDefFoundError: ImpulseResponseFunction Caused by: java.lang.ClassNotFoundException: ImpulseResponseFunctio at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:323) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:268) Could not find the main class: ImpulseResponseFunction. Program will exit. Why can't it find ImpulseResponseFunction?
The program works all fine and dandy when I run in runtime within Eclipse. The problems arise when I try to create and run jar file.
If it helps I am running Ubuntu.
Any help with this would be greatly appreciated.
Thanks
jarwith-classpath?jardoesn't have a-classpathoption. It just thinks you're trying to add a file called-classpath.