My teacher gave me a program which will maintain the attendance of some class daily , i have made it fully , i use eclispe IDE -JAVA SE , there are a lot of swing components in it like textfields,checkboxes,JList etc so there are Listener classes for the components.

constructor makes the frame and loads everthing on it , there is a CUSTOMAboutDialog inner class that shows the information of the program creator , a ActionListener class for all JButtons , and 2 more methods along with the main function , 1 gif n 1 jpg is also used

So i have made a Runnable JAR File , using File->Export option , i selected the
"extract required libraries int generated JAR" option , then when i try to run it using
java -jar filename.jar in cmd, it says it cannot locate it

C:\Documents and Settings\Administrator\Desktop>java -jar Attendance Maintenance
.jar
Unable to access jarfile Attendance


n yeah the file is definately on the desktop
/***********************************************************************************/

C:\Documents and Settings\Administrator\Desktop\Attendance Classes>java Attendan
ce_Maintenance
Exception in thread "main" java.lang.NoClassDefFoundError: Attendance_Maintenanc
e (wrong name: attendance_Maintenance/Attendance_Maintenance)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: Attendance_Maintenance. Program will exit.

Attendance_Maintenance is the main class name , the main function is there inside that class with 2 more inner Listener classes , 2 more functions , and i have added the bin path of jdk to the environment variable path

Anybody got suggestions about how to run the JAR file it says it cannot locate it even if it is in the same directory and it has got the same name as that i typed in the cmd prompt

THANKS IN ADVANCE:)

Recommended Answers

All 2 Replies

Syntax is:

java -jar jarfile.jar arguments

so assuming the .jar file is Maintenance.jar the command should be

java -jar Maintenance.jar

optional parameter

java -jar Maintenance.jar Attendance

Syntax is:

java -jar jarfile.jar arguments

so assuming the .jar file is Maintenance.jar the command should be

java -jar Maintenance.jar

optional parameter

java -jar Maintenance.jar Attendance

What does the optional parameter stand for , is it the main class name in jar file or something else?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.