Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Null pointer exception when instantiating Jython interpreter

25 views
Skip to first unread message

Robert Oschler

unread,
Nov 3, 2002, 5:10:55 PM11/3/02
to
Hello,

I'm running NetBeans 3.34 with the Sun JDK/SDK version 1.4.1_01b, on a Win
2k box. I'm trying to integrate Jython 2.1 into my test app. I created a
Frame where originally I tried starting the Jython interpreter when a button
was hit. I got the error dump shown below. I did some Google searching and
checked the Jython users mailing list archives, and saw some posts regarding
Jython and multi-threading problems. So I moved the code that tries to
instantiate the jython interpreter into the static main() function that
creates and shows the Frame. Same error dump. Does anyone know what to do
here?

thx

-------------------------------------------------

Error Dump caused by line> PythonInterpreter interp = new
PythonInterpreter():

java.lang.NullPointerException
at
org.python.core.PyJavaClass.lookup(PyJavaClass.java:39)
at
org.python.core.PyObject.<init>(PyObject.java:46)
at
org.python.core.PySingleton.<init>(PySingleton.java:8)
at
org.python.core.PyNone.<init>(PyNone.java:7)
at
org.python.core.PySystemState.initStaticFields(PySystemState.java:34)
at
org.python.core.PySystemState.initialize(PySystemState.java:320)
at
org.python.core.PySystemState.initialize(PySystemState.java:294)
at
org.python.core.PySystemState.initialize(PySystemState.java:287)
at
org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:61)
at
org.python.util.PythonInterpreter.<init>(PythonInterpreter.java:45)

Robert Oschler

unread,
Nov 4, 2002, 12:34:41 PM11/4/02
to

"Robert Oschler" <Osc...@earthlink.net> wrote in message
news:P9hx9.41918$Lg2.11...@news2.news.adelphia.net...

> Hello,
>
> I'm running NetBeans 3.34 with the Sun JDK/SDK version 1.4.1_01b, on a Win
> 2k box. I'm trying to integrate Jython 2.1 into my test app. I created a
> Frame where originally I tried starting the Jython interpreter when a
button
> was hit. I got the error dump shown below. I did some Google searching
and
> checked the Jython users mailing list archives, and saw some posts
regarding
> Jython and multi-threading problems. So I moved the code that tries to
> instantiate the jython interpreter into the static main() function that
> creates and shows the Frame. Same error dump. Does anyone know what to
do
> here?
>
> thx
>
<snip>

Hello,

Ok, it turns out it was a simple problem due to my Java inexperience. I'm
posting the answer here so others can find it. I had added the path to the
directory that contained the jython.jar file, in my case "C:\jython-2.1".
What I needed to do was add the jar file itself as a path in the class path,
that is, "C:\jython-2.1\jython.jar". It is seems to me, especially after
examining the URLClassLoader definition page, that jar files are treated as
a "path" or "directory" that contains other files. All I had to do was add
the jar file to the path and everything worked fine.

In NetBeans 3.4 you would mount "jython.jar" by navigating to the jar file,
usually in the jython top level directory, by right clicking on the
"Filesystems" root node key in the Explorer pane, then Mount, then Archive
Files. Using the file explorer dialog box just locate "jython.jar", select
it, and click "Finish".

In JBuilder, you would add the library from the Project
Properties->Libraries->Add Library item.

NOTE: when you first initialize the python interpreter for the very first
time ever, the system package manager will take a significant amount of time
to process several other dependent archive (jar) files, especially "rt.jar",
before returning from the initialization call. Just relax and let it
proceed normally. It will only happen the first you ever initialize a
python interpreter and not afterwards.

Hope this helps.

thx

0 new messages