I have to create a JAR file (without using any IDE)
That's what I'm doing:
I got a folder named Project, this is the main one, in this one i two folders and a pdf file.
one named ClassFiles that contains all the ".class" files of my project
the other one named JavaFiles that contains all the ".java" files.
the file is a relation that i have to include, nothing relevant though, and is called Info.pdf.
The error i have is this:
My main class (is redundant, i mean the starting one, with "public static void main(String[] args)") is called Main
the command line i'm using is:
jar -cfe Project.jar ClassFiles.Main JavaFiles ClassFiles INFO.pdf
i get the error Could not find the main class: ClassFiles.Main. Program will exit
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 Main with and another Main$1.
I need to give this JAR tomorrow, so i'm quite desperate.
Thank you in advance!
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
@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)
@ 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
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.
I have the Main.class in the ClassFiles directory and Main.java in the JavaFiles dir
That's exactly what i did and the result:
ascal@AscaL ~/Desktop/Progetto $ jar -cfe Progetto.jar ClassFiles.Main ClassFiles JavaFiles Info.pdf
ascal@AscaL ~/Desktop/Progetto $ java -jar Progetto.jar
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 of Main.java