Menu

Unable to access class in Jar file

Feedback
2006-04-12
2013-04-25
  • Rob Marchetti

    Rob Marchetti - 2006-04-12

    I am trying to access a Sybase driver
    I added the "jconn3.jar" Jar file

    Print out the classpath which is correct, but it is still not finding SbyDriver.class file in the Jar. I have checked everywhere to see if anyone has done this and I have not.

    I can access this thru Jython using zxJDBC without a problem so I am trying to figure out why it won't work here.

    There is some defintely advantages of running this in Jpype, but if this is a limitation it would be nice to know. I am stuck at this point!

    Any help would be appreciated!

    Rob

    Here is the code:
    ##################################################
    from jpype import *
    import os

    pathName = os.path.dirname(sys.argv[0])
    fullPathName = os.path.abspath(pathName)
    mypath1 = fullPathName+ "%s" % ("\\lib\\jconn3.jar")
    mypath2 = fullPathName+ "%s" % ("\\lib\\ant.jar")
    startJVM("D:\\j2sdk1.4.2_08\\jre\\bin\\client\\jvm.dll", "-ea", "-Djava.class.path=%s;%s" % (mypath1, mypath2))

    java.lang.System.out.println("MYCLASSPATH : " + java.lang.System.getProperty("java.class.path"));

    userId = "userId"
    password = "password"

    sybDriver = JPackage('com').sybase.jdbc.SybDriver

    driverName="""com.sybase.jdbc3.jdbc.SybDriver""";
    server_url="jdbc:sybase:Tds:10.150.4.103:1600";

    java.lang.Class.forName(driverName)
    sybDriver.setVersion(com.sybase.jdbcx.SybDriver.VERSION_5);
    connection = DriverManager.getConnection(server_url, userId, password);
    statement = connection.createStatement();

    shutdownJVM()

     
    • Rob Marchetti

      Rob Marchetti - 2006-04-12

      Output after running the file:

      MYCLASSPATH : C:\automation\Javatester\src\lib\jconn3.jar;C:\automation\Javatester\src\lib\ant.jar
      Traceback (most recent call last):
        File "C:\automation\Javatester\src\Jpye_Test.py", line 40, in ?
          java.lang.Class.forName(driverName)
      jpype._jexception.java.lang.ExceptionPyRaisable: java.lang.ClassNotFoundException: com/sybase/jdbc3/jdbc/SybDriver

       
    • Noel O'Boyle

      Noel O'Boyle - 2006-04-20

      This is on Windows right? Are you sure that there should be semicolon in the java.class.path? Try a : instead. Also try just one path and see can it find it.

      BTW, you should create paths using os.path.join("path1","path2","filename") instead of using \\ all the time (as this will only work on Windows).

      Regards,
      Noel

       
    • Pierce Wetter

      Pierce Wetter - 2006-09-27

      Actually, its neither COLON or SEMICOLON, its:

      jpype.java.lang.System.getProperty("path.separator")

      So if you have a list of file paths in "jars":

      jpype.java.lang.System.getProperty("path.separator").join(jars)

      Oh, this question is from April. (That's the problem with browsing forums on the web.) Well, I'll post anyways for those like me who are browsing the forums.

       

Log in to post a comment.