Note that there are some explanatory texts on larger screens.

plurals
  1. POJAR main class not found problem
    text
    copied!<p>I have to create a JAR file (without using any IDE)</p> <p>That's what I'm doing:</p> <p>I got a folder named Project, this is the main one, in this one i two folders and a pdf file.</p> <p>one named <strong>ClassFiles</strong> that contains all the ".class" files of my project</p> <p>the other one named <strong>JavaFiles</strong> that contains all the ".java" files.</p> <p>the file is a relation that i have to include, nothing relevant though, and is called Info.pdf.</p> <p>The error i have is this:</p> <p>My main class (is redundant, i mean the starting one, with "public static void main(String[] args)") is called <strong>Main</strong></p> <p>the command line i'm using is:</p> <p><code>jar -cfe Project.jar ClassFiles.Main JavaFiles ClassFiles INFO.pdf</code></p> <p>i get the error <code>Could not find the main class: ClassFiles.Main. Program will exit</code></p> <p>PS: in the ClassFiles folder i have a lot of classname$1, classname$2 files. i don't know if it's relevant. I even have the <strong>Main</strong> with and another <strong>Main$1</strong>. </p> <p>I need to give this JAR tomorrow, so i'm quite desperate.</p> <p>Thank you in advance!</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: ClassFiles/Main (wrong name: Main) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: ClassFiles.Main. Program will exit </code></pre> <p>@erikson: ClassFiles is just a folder i made to contain all the .class, nothing more... there is no package in what i did (it was the default one when i used Eclipse)</p> <p>@ Dave Newton: sorry man, (first of all thank you), could u be a little more specific? i'm not understanding what i should do. i'm not really good with this stuff</p> <p>ah, if you mean that the package is not called Project but Progetto is just becouse i translated it in english. not sure if that's what you are referring too.</p> <p>I have the Main.class in the ClassFiles directory and Main.java in the JavaFiles dir</p> <p>That's exactly what i did and the result:</p> <p>ascal@AscaL ~/Desktop/Progetto $ jar -cfe Progetto.jar ClassFiles.Main ClassFiles JavaFiles Info.pdf</p> <p>ascal@AscaL ~/Desktop/Progetto $ java -jar Progetto.jar</p> <p>Exception in thread "main" java.lang.NoClassDefFoundError: ClassFiles/Main (wrong name: Main) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266)</p> <p>Could not find the main class: ClassFiles.Main. Program will exit.</p> <p>//Code of Main.java</p> <p><a href="http://pastebin.com/Xh9emcYH" rel="nofollow">http://pastebin.com/Xh9emcYH</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload