Default style (Cherry Eve). Switch styles (Capricorn). XML Feed Calendar
All | Games | General | Java | Music | NetBeans
20060721 Friday July 21, 2006

ScriptModule - bugfixes

Sven Reimers has found a major bug in the NetBeans scripting module. The script engines were not initialize when you open a script console; so when you entered any command, the script engine will choke. I've fixed the problem. Thanks Sven.

While was using the jython script engine to test the console and I found a few problems with jython

  • The jython engine does not honour the classloader in the ScriptEngineManager. The ScriptEngineManager allows you to associate a classloader when you are instantiating it. The idea is to be able to load and create script engines dynamically. I can get a reference to Jython's script engine but when I tried to execute a statement, print(“hello world”), I got a class not found exception on PyRunnable. I was pretty sure that PyRunnable was in the URLClassloader's path that I passed to ScriptEngineManager. Another Sun colleague, Sundar has told me the workaround but I completely forgot about it. It is not enough to have the jython's Jars in the classloader, you have to explicitly set the classloader to the current thread's context classloader.

  • I could not redirect jython's output to the console. There is a method in the ScriptContext call setWriter that allows you to redirect the engine's output to wherever you like. Again, jython is not honouring this. So the output is displayed to System.out. For those who are using the console, I suggest you write a globals.py file; stick this under console directory. In globals.py redirect all output to Console.println(). Console is an exported object. See the help for more details

  • The jython engine comes with a set of Python libraries. You can find this under jython_home/lib/python. I do not know Python to test out the environment, so if you are testing, please let me know how this is resolved. I know that you have to set python.path. But currently this is not set, so what is the default?

Okay, the NBMs are available here (ScriptEngine) and here (Windoows). The source is available here. Once I've got a reasonably working version, I'll upload this to http://scripting.dev.java.net site.

Jul 21 2006, 01:01:26 AM SGT Permalink