we have a standalone project. we are using Java DB and we are writting our code on netbeans. we can conncet to DB with using IDE and we can do what we want but when we make it jar file it couldnt connect to database . how can we solve this problem thanks
Asked
Active
Viewed 333 times
-1
-
Please provide the error you receive when executing your jar file, otherwise we can't help. – Manuel Nov 27 '12 at 13:10
-
sure when we execute the file on the IDE we can register as a user but when we make it jar file we cant register . it doesnt reach the database – user1830857 Nov 27 '12 at 13:18
-
1Do you have some kind of logging output/printed exception stracktrace which you can share? Otherwise we can just guess whats wrong. – Manuel Nov 27 '12 at 13:46
-
How are you creating the jar file? – Kai Nov 28 '12 at 08:45
2 Answers
0
The database driver has to be in classpath when you run your application as JAR. When you start the application in eclipse the driver is found in the build path. That's why your application works here.
Another solution would be to embed the driver's JAR in your JAR file.

Kai
- 38,985
- 14
- 88
- 103
-
-
I don't know how you are building your jar file... So I can't tell you how to extend your build to add the driver. I'm sure you will find a similar question here on SO. – Kai Nov 27 '12 at 13:27
0
first check where is your jar located,most probably it is outside the project thats why error occurs. put them in your project and set path properly in classpath file like :
<classpathentry exported="true" kind="lib" path="WEB-INF/lib/castor-1.1.2-commons.jar"/>
right now if you see your path is look like :
<classpathentry exported="true" kind="lib" path="D:/apache-tomcat-6.0.14/apache-tomcat-6.0.14/lib/servlet-api.jar"/>
which is wrong.
provide your classpath file and error log if still error occurs.

Jubin Patel
- 1,959
- 19
- 38
-
I have checked it it is located in the project file . While netbeans open I can register and log in but when I closed the IDE I cant log in and register. I couldnt understand your explanation could you please extend more. – user1830857 Nov 27 '12 at 13:51
-
provide your .classpath file then explain issue if its same as i think – Jubin Patel Nov 27 '12 at 13:54
-
C:\Users\ARSLAN\Desktop\LanguageAid\dist\LanguageAid.jar this is the classpath of jar file. – user1830857 Nov 27 '12 at 14:00
-
here is the problem add your jar file in project folder with name lib folder and then change this particular path like `path="lib/LanguageAid.jar"` – Jubin Patel Nov 27 '12 at 14:02
-
your program can not find location of jar file,do this for all jar files – Jubin Patel Nov 27 '12 at 14:04
-
I have changed the classpath like your says but nothing changed . still jar file couldnt reach the database – user1830857 Nov 27 '12 at 14:17