question-circle Using jar in jython

8 years 8 months ago #2231 by jmfavre
I'm trying to use apache poi to create an interface with excel from my script, but I have trouble in importing the corresponding jar in jython.

-> is it possible to add some java .jar somewhere and use them in a script?

In fact, I've tried to put the jar somewhere, add then them in the sys.path jython variable, but while this work fine for python modules I develop (see the CoExplorer module I delivered), it seems that this is not working for java packages.

I know that modelio has its own class loader, but I'm wondering why using sys.path in jython do not do the job as expected.

Any idea?

Please Log in or Create an account to join the conversation.

8 years 8 months ago - 8 years 8 months ago #2244 by chm

as pan said right here :

pan wrote: I think it's not possible to load new jars for using with Jython. Modelio has its own class loading mechanism and it does not permit to take into account jars which are not brought by Modelio...
And it's not possible to add jars at runtime...

The sys.path is modified by modelio itself, it may be the reason adding something in it doesn't work.

It might be possible to create and use your own UrlClassLoader including your jar, but I'm not sure how to do it in a script... By the way, I'm sure it is possible in a java module, as DocumentPublisher is doing it to load its templates jars for execution.

Hope this helps,


Please Log in or Create an account to join the conversation.

Moderators: chmcma
Time to create page: 0.034 seconds
^ Back to Top