Results 1 to 7 of 7
  1. #1
    Bhavana Jain is offline Member
    Join Date
    Mar 2012
    Posts
    6
    Rep Power
    0

    Default 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

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Class not found exception

    Unresolved compilation problem:
    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.

    I have follwed all the steps correctly i.e, setting the classpath
    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.

  3. #3
    Bhavana Jain is offline Member
    Join Date
    Mar 2012
    Posts
    6
    Rep Power
    0

    Default 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

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default Re: Class not found exception

    compiler is unable to load the class org.hsqldb.javaDriver
    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.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Class not found exception

    Quote Originally Posted by Bhavana Jain View Post
    Mine code is
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Bhavana Jain is offline Member
    Join Date
    Mar 2012
    Posts
    6
    Rep Power
    0

    Default 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

  7. #7
    Bhavana Jain is offline Member
    Join Date
    Mar 2012
    Posts
    6
    Rep Power
    0

    Default Re: Class not found exception

    Here the error lies in the code where I forgot to write the exception for classnotfound

Similar Threads

  1. Replies: 1
    Last Post: 02-10-2012, 10:17 PM
  2. Class not found exception for the servlet class.
    By mazem in forum Java Servlet
    Replies: 2
    Last Post: 08-24-2011, 10:20 AM
  3. Replies: 6
    Last Post: 07-25-2011, 11:34 AM
  4. Class not found Exception
    By surendra in forum Java Servlet
    Replies: 8
    Last Post: 06-09-2011, 01:52 PM
  5. class not found exception while using IKVM to create exe for c#
    By manjunath k reddy in forum New To Java
    Replies: 0
    Last Post: 02-21-2009, 07:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •