• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PythonInterpreter.initialize

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
We're working on a project using Java and Python. While executing PyInterpreter.initialize() we encountered some problems.
The code we are using looks like this:
import java.util.*;
import org.python.util.*;
import org.python.core.*;
public class SimpleEmbedded {
public static void main(String []args) throws PyException {
PythonInterpreter interp;
Properties props=new Properties();
props.setProperty("python.path","/home/kdg/jython-2.1/Lib");
PythonInterpreter.initialize(System.getProperties(),props,args);
interp = new PythonInterpreter();
}
}
This code generates the following error-message:
Exception in thread "main" java.lang.NullPointerException
at org.python.core.PyJavaClass.lookup(PyJavaClass.java:43)
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:10)
at org.python.core.PySystemState.initStaticFields(PySystemState.java:396)
at org.python.core.PySystemState.initialize(PySystemState.java:375)
at org.python.core.PySystemState.initialize(PySystemState.java:348)
at org.python.util.PythonInterpreter.initialize(PythonInterpreter.java:40)
at SimpleEmbedded.main(SimpleEmbedded.java:16)
Can anyone help us ?
Thanks,
Ann Carpentier
Kenny Mees
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I first changed the python.path property string to have the value "c:\\jython-2.1\\Lib" appropriate to my system. I get the following output when compiling and running your program:

That is, it compiles and runs without any problem. I'm using java 1.4.2 on Windows NT4

By the way would you please change your displayed name to conform to JavaRanch's Naming Policy. You can change it here.
Thanks
[ February 06, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the following compiles and runs successfully:

Here's the console output:
 
Ann
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Barry,
Although we think we tried everything, including the steps you gave us in your reply, we tried one more time with your instructions and guess what...
IT WORKED.

Thank you very much for your quick reply and help.
Ann Carpentier
Kenny Mees
[ February 06, 2004: Message edited by: Ann & Kenny ]
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic