Results 1 to 18 of 18
Thread: JAR files+ MySQL
- 03-06-2011, 08:33 AM #1
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
JAR files+ MySQL
I have made an simple application in which I have used MySQL to store data. When run the code in netbeansIDE,it works well.
But when I click double on the jar file,it cant access the MySQL.
How can I solve this?
Thanks in advancedLast edited by UJJAL DHAR; 03-06-2011 at 05:40 PM. Reason: SOLVED
- 03-06-2011, 11:21 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
You jar file should have a manifest entry that manages the MySQL jar file in its classpath line; read the documentation.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-06-2011, 12:55 PM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
I have read the documentation. I have failed to get the main point.
Please help me a bit more.
I am using Netbeans IDE 6.8 and mysql-connector-java-5.0.8-bin.jar
What should I do now?
Please help me.
- 03-06-2011, 01:12 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Are you sure you've read the documentation? It's all in there; oh well, put the following lines in your manifest entry:
Oh, and b.t.w. Netbeans has nothing to do with this; also make sure that you put the actual values for the < ... > placeholders above.Java Code:Main-Class: <your main class> Class-Path: <path to>/mysql-connector-java-5.0.8-bin.jar
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-06-2011, 02:20 PM #5
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
My manifest file is aaa.mf
Here my Main class is Main.java.Java Code:Main-Class: Main Class-Path: C:/Program Files/Java/jdk1.6.0_01/jre/lib/ext/mysql-connector-java-5.0.8-bin.jar
Before adding Shop.jar is working without accessing database.
But after adding manifestJava Code:jar cvfm Shop.jar aaa.mf
it shows
I think I am going too silly.please help me.Java Code:Exception in thread "main" java.lang.NoClassDefFoundError: Main
- 03-06-2011, 02:32 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
- 03-06-2011, 03:00 PM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
Oh, then what will be the commands ?
Do you have any link or anything?
- 03-06-2011, 03:15 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
- 03-06-2011, 03:19 PM #9
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
this time I have executed
[code]
jar uf Shop.jar mysql-connector-java-5.0.8-bin.jar
[code]
And there was no error executing this.But still database is not accessible. Should I add more files.Then what they are?
mysql-connector-java-5.0.8-bin.jar is JDBC connector which i have used to connect netbeans with MySQL.Is it okay to add?
- 03-06-2011, 04:19 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Now you have added that MySQl jar file to your own jar file; the jar tool doesn't mind but adding jars to a jar never works; never. You are supposed to add your own .class file(s) to that jar like your Main.class file; don't just guess and add all sorts of files to your .jar file hoping that it would work.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-06-2011, 04:28 PM #11
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
Now this is working if I run it with command promt writing
java -jar Shop.jar
but When clicking double database is not accessing.
Java Code:In Filetypes JAR files are executing with "C:\Program Files\Java\jre1.6.0_01\bin\javaw.exe" -jar "%1" %* in my pc
- 03-06-2011, 04:48 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
- 03-06-2011, 05:35 PM #13
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
No..
I just change this
"C:\Program Files\Java\jre1.6.0_01\bin\javaw.exe" -jar "%1" %*
to
"C:\Program Files\Java\jdk1.6.0_01\bin\java.exe" -jar "%1" %*
And its working.Thanks a lot.my problem is solved.
- 03-06-2011, 05:59 PM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Last edited by JosAH; 03-06-2011 at 06:05 PM.
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-06-2011, 06:20 PM #15
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
No no....lets review...
I have prepared a Restaurant management system using MySQL+Netbeans.A JAR file was created by which we can execute the system only with double click.But the jar file was not capable of accessing MySQL.
My Question was how to make sure that jar file can access database?
Your answer was to add the mysql connector to the jar.
I have added it as your direction.But when I was running the JAR file using command prompt,it works.java -jar Shop.jar
But it didnt work with double click.
Because ofThen I changed it to"C:\Program Files\Java\jre1.6.0_01\bin\javaw.exe" -jar "%1" %*.and now its working"C:\Program Files\Java\jdk1.6.0_01\bin\java.exe" -jar "%1" %*
Thats it.
- 03-06-2011, 06:26 PM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
- 03-06-2011, 06:31 PM #17
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
I m not sure also about the fact.
I will search for the answer of a question in future but not today.
Thanks a lot JosAh for being with me.What is the difference between javaw.exe of JRE and java.exe of JDK
- 03-07-2011, 11:12 AM #18
Moderator
- Join Date
- Apr 2009
- Posts
- 10,448
- Rep Power
- 16
I mentioned this on the other thread over in Databases where you were "helping" someone with a problem but:
Class-Path: C:/Program Files/Java/jdk1.6.0_01/jre/lib/ext/mysql-connector-java-5.0.8-bin.jar
You do not want to be putting anything in there.
That's a mistake, and possibly why Netbeans hasn't done what it should, which is stick them mysql connector jar into your dist directory, and a proper entry into the Manifest.
Fix that mistake, stick the jar file in a lib directory under your Netbeans project and reference it properly, and Netbeans will build you a nice jar file, with associated lib in a dist directory.
Similar Threads
-
Convert avi, mpeg, wmv media files to .flv files in java code
By vinay1497 in forum New To JavaReplies: 8Last Post: 07-30-2010, 05:47 PM -
Storing video files in mysql database
By mrvigneshmca in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2009, 03:50 PM -
MySQL/JDBC Mysql query output
By thelinuxguy in forum Advanced JavaReplies: 4Last Post: 02-13-2009, 01:57 AM -
Behaving text files like binary files
By Farzaneh in forum New To JavaReplies: 2Last Post: 08-27-2008, 03:20 PM -
how to convert mpeg files to .wav files
By christina in forum New To JavaReplies: 1Last Post: 08-06-2007, 04:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks