Results 1 to 10 of 10
- 04-26-2012, 04:16 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
ClassNotFoundException from jar file
I have developed a programm that connects to a Firebird database.
I use Eclipse as a development environment.
Executing the programm in Eclipse it works ok.
When I make an executable jar file it gives a ClassNotFoundException caused by the "Class.forName(DBConst.DRIVERNAAM);" statement.
Below some details from the code.
What am i missing?
Java Code:private void maakVerbinding() throws DatabaseException { try { //DriverManager.setLogWriter(new PrintWriter(System.out)); Class.forName(DBConst.DRIVERNAAM); con = DriverManager.getConnection(DBConst.URL, DBConst.GEBRUIKERSNAAM, DBConst.WACHTWOORD); } catch (ClassNotFoundException e) { throw new DatabaseException("De klasse voor het laden van de driver kan niet gevonden worden"); } catch (SQLException e) { throw new DatabaseException("Er kan geen verbinding met de database worden gemaakt"); } }Last edited by JosAH; 04-26-2012 at 04:54 PM. Reason: added [code] ... [/code] tags.
- 04-26-2012, 04:22 PM #2
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: ClassNotFoundException from jar file
Please put [code][/code] tags around your Java code.
- 04-26-2012, 04:44 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: ClassNotFoundException from jar file
Ok, I will do that next time.
- 04-26-2012, 04:54 PM #4
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: ClassNotFoundException from jar file
There's no time like the present! Please edit that post and add them.
- 04-26-2012, 04:56 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
- 04-26-2012, 06:03 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Re: ClassNotFoundException from jar file
In your catch blocks either log the original exception (e.printStackTrace()) or attach it to the new exception.
You are losing a ton of useful information about where and what exact exception is being thrown (like what class is not being found).Please do not ask for code as refusal often offends.
- 04-26-2012, 06:30 PM #7
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: ClassNotFoundException from jar file
Thank you for fixing the tags, next time I know how to do it.
Ok, so I'm missing "org.firebirdsql.jdbc.FBDriver" in my classpath.
I checked the jar file content with the jar statement and the class mentioned above is indeed missing.
I'm new to Java but I understand the basics from the jar command and manifest files.
So maybe my next question is stupid.
Leaves me with the problem where do I find the jar file that contains the class "org.firebirdsql.jdbc.FBDriver".
I looked on my C drive and can't find a jar file that rings a bell.
How do I know which jar file it is and how does Eclipse knows it?
There the programm runs without a problem.
- 04-26-2012, 06:41 PM #8
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: ClassNotFoundException from jar file
You must have the Firebird Eclipse plugin installed and your project's build path has been setup to have Firebird included. I would suggest you visit the Firebird homepage and look for their documentation. Having the Eclipse plugin may not be sufficient for you to run your application outside of Eclipse. There may be Firebird runtime you have to install and include in your classpath. That should all be in their documentation.
- 04-27-2012, 09:38 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,460
- Rep Power
- 16
Re: ClassNotFoundException from jar file
I've not used Firebird, but presuming it's a standalone database, then you should have a jdbc driver jar for it somewhere.
That should be all you need to have on your runtime classpath (note, classpath, not CLASSPATH).Please do not ask for code as refusal often offends.
- 04-27-2012, 04:17 PM #10
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
Re: ClassNotFoundException from jar file
I was looking further around on my C drive and I found the driver class in a directory "..\Java\jdk1.6.0_04\jre\lib\ext\Driver Firebird\org\firebirdsql\jdbc" with the name "FBDriver.class".
Also on the Firebird website I found the jdbc driver.
One option is that I download the driver and with a manifest file add it to my jar command.
Is that the way to do it or are there other and easier options?
Similar Threads
-
ClassNotFoundException!! Oh BOY!!
By Joel in forum New To JavaReplies: 13Last Post: 08-26-2011, 09:47 AM -
ClassNotFoundException...
By providence in forum JDBCReplies: 2Last Post: 02-02-2011, 06:45 PM -
ClassNotFoundException - only for one class file, but others OK
By Gordy.Liang in forum New To JavaReplies: 4Last Post: 12-30-2010, 01:23 PM -
ClassNotFoundException
By meprasobh in forum New To JavaReplies: 2Last Post: 10-17-2010, 03:32 PM -
ClassNotFoundException
By oontvoo in forum Java AppletsReplies: 7Last Post: 05-13-2010, 11:09 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks