From: Andrea <mar...@go...> - 2009-02-27 20:22:20
|
Jacob Fenwick wrote: > Hmm, it didn't work. Here's what I tried. > > I have a class in foo/Test.java: > package foo; > > class Test { > public String print() { > return "Printing\n"; > } > } > > > I compile it, then create a jar: > jar -cvf classes.jar foo > > > Then I run these commands in jython: >>>> import sys >>>> sys.path.append('/Users/jacob/projects/djython/jython_test/classes.jar') >>>> from foo import Test >>>> t = Test() >>>> t.print() > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'foo.Test' object has no attribute 'print' >>>> > > > Hmmm. If I dir the t object I don't find a print function so I know it's > not there. > > I feel like these steps I've followed should be working. If someone has > a few minutes to look at it and tell me what I'm doing wrong I'd greatly > appreciate it. > > Jacob Hi, I have an issue with the method via "sys.path.append()" when the package name starts with an already existing name. If you replace "package foo" -> "package org.foo" then it does not work. With something like "package newname.foo" then it is OK. It still works if one uses the CLASSPATH method. It seems that it only discovers "new" names and not existing one. (org already exists in >>> dir(org) ['GNOME', '__name__', 'ietf', 'jcp', 'omg', 'python', 'w3c', 'xml'] All that with jython 2.5b1 Andrea |