[jython.jar] Got java.lang.ExceptionInInitializerError while initializing PythonInterpreter
Po-Yu Chuang <[email protected]>
| Newsgroups | gmane.comp.lang.jython.user |
|---|---|
| Message-ID | <CANutaR_22Hk9Ag3qJ5TfWR+1pa9y=kbOw6SGKzrd3a8hHco6tg@mail.gmail.com> |
Hi all,
I am trying to use Python objects in a NetBeans Java project, but
failed at the very beginning.
At first, I tried to use PlyJy (https://kenai.com/projects/plyjy)
which provides JythonObjectFactory, but it failed to create Jython
object. In order to debug, I tried to paste the sample Java code on
jythonbook to my Java program instead.
http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#making-use-of-a-loosely-coupled-object-factory
Then I found that it fails while creating PythonInterpreter object.
PythonInterpreter interpreter = new PythonInterpreter();
I tried jython 2.5.3, 2.5.4-rc1, 2.7-b3. All of them gave the same
result -- I always got java.lang.ExceptionInInitializerError while
creating PythonInterpreter.
Then, I downloaded jython source and built a jython-dev.jar for
debugging and found that the exception results from the following
lines in Version::loadProperties() which is called in static init
block of Version:
final String versionProperties = "/org/python/version.properties";
InputStream in = Version.class.getResourceAsStream(versionProperties);
Version.class.getResourceAsStream() fails to get
"/org/python/version.properties" and returns null which in turn causes
Version object failed to construct and throws an exception.
"/org/python/version.properties" is indeed inside jython-dev.jar. I
don't understand why getResourceAsStream() fails.
I guessed this might be something like CLASSPATH settings or other
environment issue, so I tried to add jython.jar in CLASSPATH and tried
different environments (NetBeans 8.0.2 on Ubuntu, NetBeans 7.4 on
Windows) but still got the same result.
Any suggestion is appreciated.
Thanks,
Po-Yu
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/