Null pointer exception when instantiating Jython interpreter

Robert Oschler Oschler at earthlink.net
Mon Nov 4 12:34:41 EST 2002


"Robert Oschler" <Oschler at earthlink.net> wrote in message
news:P9hx9.41918$Lg2.11403082 at 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






More information about the Python-list mailing list