I need some help and hope I am in the right place.
I made a Java database app in a GUI. The app runs fine with no errors, and does what I want it to do. When I make the app into a .jar the app starts up but does not input data into the MySQL table. Here is the code.
I even took out the System.out.println(); and tryed again with making the .jar file still does not work.
Please read this. You appear to have posted lots of code with long lines in, so people can’t read it, but chances are none of that code is relevant to the question.
Please show us how you are trying to create the .jar, and the complete contents of the manifest file.
Sorry that the code was so long here is the SQL part of the code. It is with in the ButtonListener method of the class.
As for making the .jar file what I did was,
1. Made a MyManifest.txt file and in that i wrote Main-Class: Contact then pressed enter twice saved the file named MyManifest. Contact is the main class of my app.
2. in CMD i wrote jar cfm JarFileName.jar MyManifest.txt Contact.class ContactFrame.class ContactP$1.class ContactP$ButtonListener.class ContactP.class
The jar file works, the app runs. But as for sending data to the SQL table that does not work.
It only sends data to the SQL table if I run the app in CMD.
Did you use the -cp option when you started the jar file, or is the classpath in the manifest file? I think it is better in the manifest file. If you don’t supply a classpath, the app can’t find the jar with the connector in.
You need to supply a classpath which includes the location of the connector classes. If you go through the Java tutorials section, you find it in the section about adding other classes to the classpath.