Results 1 to 7 of 7
  1. #1
    clau8025 is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Angry Problems with CLASSPATH

    Quote Originally Posted by Norm View Post
    Where is the file: first.class? The java program is looking for it.
    Perhaps you need to add to the classpath to include the current directory.
    Try this, add a ;. to the end of the -cp:
    java -cp "D:\Sun\SDK\sqlitejdbc-v056.jar";. first[
    Hi,
    I read with attention yr recommendation and of course it works. Normally I use Scite editor when working in java.
    My program in java is very similar to that of the former inquirer and it works when using the windows md-dos console
    in the way you say (java -cp "C:\....\sqlitejdbc-v056.jar";. ConnectSQLite)
    But when I try to register the path of sqlitjdbc-v056.jar in the CLASSPATH environment variable and try to
    run the same program through Scite, it doesnt work and gives the usual excepcion...

    java.lang.ClassNotFoundException: org.sqlite.JDBC
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at ConnectSQLite.main(ConnectSQLite.java:23)
    java.lang.NullPointerException
    at ConnectSQLite.main(ConnectSQLite.java:37)

    I don't know what I'm doing wrong.
    Thanks in any way you could help.http://www.java-forums.org/images/smilies/skype/=(.gif

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,609
    Rep Power
    23

    Default Re: Problem finding SQLite JDBC driver

    Please start a new thread for your problem.

    Include the console contents when you post.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    clau8025 is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: Problem finding SQLite JDBC driver

    Quote Originally Posted by Norm View Post
    Please start a new thread for your problem.

    Include the console contents when you post.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    Thanks for yr reply

    This is the program:

    **
    * ConnectSQLite.java
    */
    //package com.javaworkspace.connectsqlite;

    import java.sql.*;

    /**
    * @author
    *
    */
    public class ConnectSQLite {
    public static void main(String[] args) {

    Connection connection = null;
    ResultSet resultSet = null;
    Statement statement = null;

    try {
    Class.forName("org.sqlite.JDBC");
    connection = DriverManager
    .getConnection("jdbc:sqlite:C:\\Program Files\\Java\\jre6\\lib\\EMPLOYEE.db");
    statement = connection.createStatement();
    resultSet = statement
    .executeQuery("SELECT EMPNAME FROM EMPLOYEEDETAILS");
    while (resultSet.next()) {
    System.out.println("EMPLOYEE NAME:"
    + resultSet.getString("EMPNAME"));
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    try {
    resultSet.close();
    statement.close();
    connection.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
    }

    The program compiles oK but when running it (on Scite editor) this is the message:
    >C:\Archivos de programa\Java\jdk1.6.0_21\bin\javac ConnectSQLite.java
    >Exit code: 0
    >C:\Archivos de programa\Java\jdk1.6.0_21\bin\java -cp . ConnectSQLite
    java.lang.ClassNotFoundException: org.sqlite.JDBC
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at ConnectSQLite.main(ConnectSQLite.java:20)
    java.lang.NullPointerException
    at ConnectSQLite.main(ConnectSQLite.java:34)
    >Exit code: 0


    This source java program is in directory:
    C:\Users\Claudio\Desktop\PROGRAMAR\JAVA\MiProyecto

    These are the CURRENT values of my system variables:
    CLASSPATH:
    .;C:\Program Files\Java\jdk1.6.0_21;C:\Program Files\Java\jre6\lib\sqlitejdbc-v056.jar;.;%DERBY_HOME%\lib\derby.jar;.;C:\Users\C laudio\Desktop\PROGRAMAR\JAVA\MiProyecto\SimpleApp ;.

    JAVA_HOME:
    C:\Program Files\Java\jre6

    PATH:
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Java\jdk1.6.0_21\bin


    Many thanks in advance for your help.
    (P.D.: I've never had more problems than when trying to install and use any database system in java.
    I have experience in installing and using PostgreSQL but not in Java. I used it with Python.
    I've installed SQLite and it works ok on console. The problem is when I try to use it in Java.
    Have the same problem when try to use JavaDB).
    Last edited by DarrylBurke; 03-26-2012 at 01:05 PM. Reason: Removed irrelevant link

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,609
    Rep Power
    23

    Default Re: Problem finding SQLite JDBC driver

    java.lang.ClassNotFoundException: org.sqlite.JDBC
    The java program can not find the class listed in the error message. You need to put the jar file containing that class's class file on the classpath.
    java -cp <JARFILE>.jar;. <CLASSNAME>
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Problem finding SQLite JDBC driver

    To add to Norms post, do not rely on CLASSPATH.
    You should always define your classpath at execution, using the -cp switch.
    One reason is that CLASSPATH is the last place Java goes to find out what classpath it should use. -cp takes precedence, and the manifest in an executable jar takes precedence over that.
    Another reason is that if you have mutliple projects on one box not all of them will want to use the same versions of jar files.
    Please do not ask for code as refusal often offends.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Problem finding SQLite JDBC driver

    Also, next time you have a question start your own thread -- they're free. This one's tow years old.

    I'm splitting the current discussion to a new thread.

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

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Problems with CLASSPATH

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

Similar Threads

  1. ClassPath
    By homka in forum New To Java
    Replies: 0
    Last Post: 10-05-2011, 01:18 PM
  2. Replies: 1
    Last Post: 05-03-2011, 02:28 AM
  3. Classpath
    By Parneel in forum Enterprise JavaBeans (EJB)
    Replies: 4
    Last Post: 04-01-2009, 12:22 PM
  4. Classpath on mac osx
    By jacobb in forum JDBC
    Replies: 0
    Last Post: 06-12-2008, 09:41 PM
  5. Set classPath?
    By rgbosque in forum New To Java
    Replies: 3
    Last Post: 02-07-2008, 02:14 PM

Posting Permissions

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