Java program is compiling in netbeans but not in CMD, package does not exist

Multi tool use
Java program is compiling in netbeans but not in CMD, package does not exist
I'm working on a shop management System program. Building this using NetBeans, Java and SQL Server. I used a Jdatepicker
in my Program. It is working well in NetBeans, but now I was trying to compile it through CMD. i'm using correct syntax, but yet it is giving me errors package org.jdesktop.swingx does not exist
with many similar errors about
import org.jdesktop.swingx.JXDatePicker;datepicker
. I have already imported 4 libearies
Jdatepicker
package org.jdesktop.swingx does not exist
import org.jdesktop.swingx.JXDatePicker;
datepicker
import javax.swing.JFormattedTextField.AbstractFormatter;
import org.jdesktop.swingx.JXDatePicker;
import org.jdesktop.swingx.plaf.basic.CalendarHeaderHandler;
import org.jdesktop.swingx.plaf.basic.SpinningCalendarHeaderHandler;
for this purpose, It is working well in NetBeans but not in cmd. I have used javac
in cmd using -classpath file address.jar
, but same error occurred.
kindly assist me in this problem Error image in CMD
javac
-classpath file address.jar
i'm using correct syntax, but yet it is giving me errors: then maybe you're not. How about telling us which precise command you're executing, and where the jar files are located?
– JB Nizet
Jun 30 at 13:58
JB Nizet! I have added them in my NetBeans Project in Libraries folder. Commands are as "javac PesticidesShop.java" and other one with classpath was as "javac -classpath ECSPestisidesShopjdatepicker-1.3.4.jar PesticidesShop.java "
– Hamza_HM
Jun 30 at 14:01
You need to create a "fat" jar. A fat jar includes all external dependencies in your application's jar. By default this does not happen. Idk if ur using a build tool such as Maven or Gradle, but you need to manually configure your build tool to include those other jars INSIDE of your jar. Also, idk how bcuz i dont use netbeans, but u can find the exact command netbeans uses and copy, paste, and run that from CMD
– Jabari Dash
Jun 30 at 14:02
Ah. So you're not trying to run your code, but you're trying to compile it. Is that right? Assuming jdatepicker is the only library you depend on, and assuming it doesn't depend on any other library, the command should be
javac -classpath E:CSPestisidesShopjdatepicker-1.3.4.jar PesticidesShop.java
. Note the :
after the drive letter E. Write all the relevant information in your question, not in comments.– JB Nizet
Jun 30 at 14:08
javac -classpath E:CSPestisidesShopjdatepicker-1.3.4.jar PesticidesShop.java
:
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Are you including the necessary library jar files with your own jar file? Have you checked the class-path in the jar's manifest file, and that it includes a path to the additional jar files?
– Hovercraft Full Of Eels
Jun 30 at 13:57