Using UCanAccess in a Jython script invoked from the command line

前端 未结 1 1354
轮回少年
轮回少年 2021-01-24 02:35

OS: Windows7, Jython2.7.0FR (\"Final Release\")

Trying to use Gord Thompson\'s solution with Jython: Manipulating an Access database from Java without ODBC

I can

1条回答
  •  粉色の甜心
    2021-01-24 02:49

    It appears that sys.path has more to do with the PATH environment variable than the CLASSPATH environment variable. The following two methods have been tested and do work with Jython 2.7.0 to run a script called "jyTest.py" from the Windows command line

    Method 1: Set the CLASSPATH from a batch file (or shell script) before launching Jython

    SET CLASSPATH=C:/Users/Public/Downloads/UCanAccess/ucanaccess-3.0.2.jar;C:/Users/Public/Downloads/UCanAccess/lib/commons-lang-2.6.jar;C:/Users/Public/Downloads/UCanAccess/lib/commons-logging-1.1.1.jar;C:/Users/Public/Downloads/UCanAccess/lib/hsqldb.jar;C:/Users/Public/Downloads/UCanAccess/lib/jackcess-2.1.2.jar;.  
    c:\jython2.7.0\bin\jython jyTest.py
    

    (For Linux et. al. that would be export CLASSPATH ..., and colon separators instead of semicolons.)

    Method 2: Use -J-cp to set the CLASSPATH when invoking Jython

    c:\jython2.7.0\bin\jython -J-cp C:/Users/Public/Downloads/UCanAccess/ucanaccess-3.0.2.jar;C:/Users/Public/Downloads/UCanAccess/lib/commons-lang-2.6.jar;C:/Users/Public/Downloads/UCanAccess/lib/commons-logging-1.1.1.jar;C:/Users/Public/Downloads/UCanAccess/lib/hsqldb.jar;C:/Users/Public/Downloads/UCanAccess/lib/jackcess-2.1.2.jar;. jyTest.py
    

    (Again, Linux and friends would need the -cp entries to be separated by colons instead of semicolons.)

    0 讨论(0)
提交回复
热议问题