Trouble importing java class with JPype

429 views Asked by At

I try desperately to import a java class in python using JPype.

It works fine most of the time, but for some reasons not for this import :

from org.apache.lucene.analysis.tokenattributes import OffsetAttribute

The debugger returns:

AttributeError: type object 'org.apache.lucene.analysis.tokenattributes.OffsetA' has no attribute 'loader'

It seems the import path is truncated as if it were too long.

1

There are 1 answers

0
DavidBu On

I found the solution.

It seems this bug is already known: https://github.com/jpype-project/jpype/issues/838

Here is the workaround I used to import my class:

OffsetAttribute = jpype.JClass('org.apache.lucene.analysis.tokenattributes.OffsetAttribute')