Is it not more simple to simply add your path in System.getProperties for java.class.path?

2011/4/15 Geoff Bache <>
Hi all,

I couldn't find anything in the docs for sys.meta_path to beware that
it didn't work on java modules/packages, so I thought I'd ask here
before reporting.

Run the following code under Jython 2.5.2

import sys

class A:
   def find_module(self, name, *args):
       print "Checking", name

sys.meta_path = [ A() ]

print "Importing xml.sax.handler..."
import xml.sax.handler
print "Importing javax.swing..."
import javax.swing

and note that when importing the Python module xml.sax.handler,
"find_module" gets called for every submodule as expected. When
importing javax.swing, it is called only once, on "javax", despite
"javax.swing" also being added to sys.modules. This seems to be the
case for any java package, i.e. only the top level interacts with
sys.meta_path, which as it's usually something like "org" or "com"
makes it not very useful.

Geoff Bache

Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization.
Jython-users mailing list



My blog and profile (
YouTube page (
Twitter (