Jython classpath question

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu Jul 17 05:30:12 EDT 2003


On Thursday 17 July 2003 03:29, Tennessee James Leeuwenburg wrote:
> Hi all,
>
> Sorry for the newb question, but Googling and FAQing didn't work. Is it
> correct that Jython can only access Java classes which are inside JAR
> archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I
> ask because I want to do groovy prototyping using Jython, and save myself
> a lot of coding overhead to try something a little out-of-the-box.
>

No you can import a java .class file.  Just make sure it's on the python path 
(sys.path)  if both .py and .class files are in the same directory then you 
need do nothing...  if not then you could add the directory containing the 
java class files to python sys.path like so:

import sys

sys.path.append("/path/to/java/class/files")


for more information / alternative suggestions look at :-

http://www.jython.org/docs/registry.html

Regards
Martin





More information about the Python-list mailing list