Results 1 to 7 of 7
Thread: Class not found exception
- 07-07-2012, 06:32 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 6
- Rep Power
- 0
Class not found exception
I am using Eclipse to write java program and I want to connect to java and open office and I have follwed all the steps correctly i.e, setting the classpath
But still I get the error
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type ClassNotFoundException
- 07-07-2012, 06:51 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
Re: Class not found exception
Compile your code before you attempt to run it. In the case of Eclipse, compiler messages will be indicated with little squiggles in the code and the message itself will be indicated with an icon in the left hand margin of the code window. Post that message if you can't understand it, and the code to which it refers.Unresolved compilation problem:
Of course we don't don't know what these steps were... But one thing to bear in mind is that the Eclipse project must be set up correctly so that classes and other resources you reference can be found by both the compiler and the runtime. Setting a CLASSPATH environment variable won't do this. The "steps" must be appropriate to Eclipse.I have follwed all the steps correctly i.e, setting the classpath
- 07-07-2012, 07:44 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 6
- Rep Power
- 0
Re: Class not found exception
Mine code is
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
public class DisplayAuthors {
static final String DATABASE_URL = "C:\\mydir\\Books";
public static void main(String[] args)
{
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try
{
Class.forName("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection("jdbc:hsqldb:file:" +DATABASE_URL, "sa", "");
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT AuthorID, FirstName, LastName FROM Authors");
ResultSetMetaData metaData = resultSet.getMetaData();
int numberOfColumns = metaData.getColumnCount();
System.out.println("Authors Table Of Books Database:\n");
for(int i=1; i<=numberOfColumns; i++)
{
System.out.printf("%-8s\t", metaData.getColumnName(i));
}
System.out.println();
while(resultSet.next())
{
for(int i=1; i<=numberOfColumns; i++)
{
System.out.printf("%-8s\t", resultSet.getObject(i));
}
System.out.println();
}
}
catch(SQLException sqlException)
{
sqlException.printStackTrace();
}
finally
{
try
{
resultSet.close();
statement.close();
connection.close();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}
}
Here compiler is unable to load the class org.hsqldb.javaDriver
- 07-07-2012, 08:54 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
Re: Class not found exception
I have never used hsqldb (so take what I suggest with a grain of salt) but I think this class is located in hsqldb.jar. You should have downloaded this jar archive at some point. Make sure this jar is included in Eclipse's project build path: ie go to Project->Properties->Java Build Path and in the Libraries tab click "Add External Jars..." and add hsqldb.jar from whereever you have it on your disk.compiler is unable to load the class org.hsqldb.javaDriver
- 07-07-2012, 09:42 AM #5
Re: Class not found exception
Why do they call it rush hour when nothing moves? - Robin Williams
- 07-07-2012, 12:37 PM #6
Member
- Join Date
- Mar 2012
- Posts
- 6
- Rep Power
- 0
Re: Class not found exception
go to Project->Properties->Java Build Path and in the Libraries tab click "Add External Jars..." and add hsqldb.jar from whereever you have it on your disk.[/QUOTE]
I have done it but still it is showing the same error please help me out
- 07-08-2012, 11:23 AM #7
Member
- Join Date
- Mar 2012
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Class Not Found Exception when 1st two of four parameters passed Constructor
By mwr1976 in forum New To JavaReplies: 1Last Post: 02-10-2012, 09:17 PM -
Class not found exception for the servlet class.
By mazem in forum Java ServletReplies: 2Last Post: 08-24-2011, 09:20 AM -
Class Not Found Exception when trying to open a .jar file
By oontvoo in forum Advanced JavaReplies: 6Last Post: 07-25-2011, 10:34 AM -
Class not found Exception
By surendra in forum Java ServletReplies: 8Last Post: 06-09-2011, 12:52 PM -
class not found exception while using IKVM to create exe for c#
By manjunath k reddy in forum New To JavaReplies: 0Last Post: 02-21-2009, 06:05 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks