[2.0.0] Jython: load("some.jar") does not put jar on java runtime classpath --- bug --- workaround

Asked by Lem on 2019-10-28

###### accepted bug: https://github.com/RaiMan/SikuliX1/issues/220

********************** workaround see comment #1


I have been using the below function in version 1.1.3 for quite a while with no issues.

def SQL(DB,User,PSW,SQL):
    from com.ziclix.python.sql import zxJDBC

    jdbc_url = DB
    username = User
    password = PSW
    driver = "org.postgresql.Driver"

    # Obtain a Connection Using the With-Statement
    with zxJDBC.connect(jdbc_url, username, password, driver) as conn:
        with conn:
            with conn.cursor() as c:


But After Sikuli 2.0.0 I receive the following error message:

[error] script [ Palette4 ] stopped with error in line 39
[error] zxJDBC.DatabaseError ( driver [org.postgresql.Driver] not found )
[error] --- Traceback --- error source first
line: module ( function ) statement
16: main ( SQLQ ) driver = "org.postgresql.Driver"
39: main ( <module> ) SQLQ(POSTGRESQL_MMA_jdbc_url,POSTGRESQL_MMA_Username,POSTGRESQL_MMA_Password,SQL,SQLAssert)
[error] --- Traceback --- end --------------

Please please assist or advise.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

Sorry, I do not have a solution for you currently. Hence I accept is as a bug.

The story behind: since Java 9, it is no longer possible to add jars to the Java classpath at runtime (at least with easy measures or hacks).

If you know how to do it, you might run your scripts with Jython directly having sikulixapi-2.0.0.jar and postgresql-42.1.4.jar on the Java classpath. The load() has to be removed in this case. You can continue to edit your script in the SikuliX IDE.

If this is not a possible workaround for you, have to stick with 1.1.3 until this is fixed.

Lem (deathbyus) said : #2

Hi RaiMan,

Thank you.

Can you help with this problem?

Provide an answer of your own, or ask Lem for more information if necessary.

To post a message you must log in.