I'm attempting to JAR my project and have it be executable. Theres a problem with the way it needs to do it. Ecclipse automatically make s abin file to hold your class files in. After compiliation it throws them in there, fine. I never put "package bin;" at the top of any of my classes and it runs without a flaw in ecclipse. However to run the main class in command line you need to be in the bin folder to launch. And to jar the entire project I figured you had to be in the root of the project in command line and specifing this command
>jar cmf Manifest.txt MyProject.jar *
with Manifest in the folder and contains
Main-Class: bin.AppDriver <Carrage Return>
but then i go to execute the jar using this command: java -jar MyProject.jar
I get the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: bin/AppDriver (wrong
name: AppDriver)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>jar cmf Manifest.txt MyProject.jar *
with Manifest in the folder and contains
Main-Class: bin.AppDriver <Carrage Return>
but then i go to execute the jar using this command: java -jar MyProject.jar
I get the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: bin/AppDriver (wrong
name: AppDriver)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)