jython import

K

Kevin Dahlhausen

Been digging and could not find the answer to this.
I'd be very grateful if someone could help.

I can't import a class from a packackge that is nested:
--
import sys
sys.path.append("hsqldb.jar")
import org.hsqldb

print dir(org.hsqldb)
v = org.hsqldb.View()
--
The output is a the dir listing of hsqldb, including View, and the
following error:

File "test.py", line 6, in ?
AttributeError: java package 'org.hsqldb' has no attribute 'View'
Signal 127

51 /testing:


Any idea why this fails? I saw other people with the same problem,
but no reasons or ideas as to how to fix.
 
Y

Ype Kingma

Kevin said:
Been digging and could not find the answer to this.
I'd be very grateful if someone could help.

I can't import a class from a packackge that is nested:
--
import sys
sys.path.append("hsqldb.jar")
import org.hsqldb

print dir(org.hsqldb)
v = org.hsqldb.View()
--
The output is a the dir listing of hsqldb, including View, and the
following error:

File "test.py", line 6, in ?
AttributeError: java package 'org.hsqldb' has no attribute 'View'
Signal 127

51 /testing:

It should work when the class is public.
Is the View class private or package private in package org.hsqldb?

You can make jython look into java private things by
setting python.security.respectJavaAccessibility to false in
jython's registry:
http://www.jython.org/docs/registry.html

It's better to respect java accessibilty, though.

Regards,
Ype
 
K

Kevin Dahlhausen

Thanks. (Had tried both). Turns out I was running into issues
setting the classpath correctly (cygin bash, calling native win java,
it's easy to miss-step when adding paths with spaces).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top