0

I am building a small software which requires the JDateChooser component. In the images below, I added the classpath for jcalendar.jar to "Environment Variables" and I also created a new library and added jcalendar.jar to it as shown in the image.

Everything is fine, I can run the software and nothing wrong with it, but when I try to run the jar file of the software on different PC, and I got the error below. It seems to me that I have provided the wrong classpath for it. Please correct me if I am wrong, and any ideas how to fix this?

Thanks.

    C:\Users\user>java -jar C:\Users\user\Desktop\SmallProject.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
        at smallproject.SmallProject.main(SmallProject.java:19)
Caused by: java.lang.ClassNotFoundException: com.toedter.calendar.JDateChooser
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 1 more

C:\Users\user>

This is my classpath.

enter image description here

and this is my jar that I added to netbeans.

enter image description here

Kenny
  • 63
  • 1
  • 1
  • 6
  • 2
    `JCalendar.jar` should be in your project's `dist` folder, along with `README.TXT`. – Catalina Island Oct 17 '22 at 16:04
  • Hi Catalina, Yes. That's correct. I was sending only the jar file, not the dist folder. That's why I got the error. Problem solved. Thanks :) – Kenny Oct 19 '22 at 07:35
  • Glad to help; also look at [Compiling and Running a netbeans GUI Application in Unix commandline](https://stackoverflow.com/questions/6554330/compiling-and-running-a-netbeans-gui-application-in-unix-commandline) – Catalina Island Nov 04 '22 at 16:58

0 Answers0