Thanks everyone for your help! I finally got it up and running, and it worked splendidly. You may be interested in knowing, Kent, that the returned PyObject is not in fact a PyInt - I worked around this by calling toString on it and then using
Integer.parseInt. I'm sure there's a better way, but it worked fine. Again, thanks much!
jython.jar must be in your compile classpath.
Jake Eakle wrote:
> Thanks! The code is all set up now, but I am still having a bit of a problem
> - it can't find org.python.core or org.python.util.PythonInterpreter. I'm
> compiling using javac in a Mac OS X terminal, and both the java files and
> the jythonRelease_2_2alpha1 folder are both in the home directory. I tried
> compiling the example you pointed me to, from its default position in the
> Jython file heirarchy, and it gave the same errors. I installed Jython
> fully, etc. and I'm not sure how to proceed. Help would be much appreciated.
> On 3/24/06, Kent Johnson <firstname.lastname@example.org> wrote:
>>Jake Eakle wrote:
>>>I know nothing whatsoever about Python. I just downloaded Jython oin the
>>>recommendation of someone in some forum responding to a question about
>>>how to evaluate strings from Java - it turns out that the standaard
>>>libraries provide no real way to do this.
>>>I have a very simple situation - I have a string with a basic
>>>mathmatical expression, like "3+45*2" and I want to store it's value in
>>>an int from a Java program.
>>This example shows how to do what you want:
>>I'm not sure but I think the returned PyObject will actually be a
>>PyInteger and you can call getValue() on it to get the result.
>>You should know that eval() is a security hole that leaves you open to
>>denial-of-service attacks and probably data loss. Don't eval() strings
>>from an untrusted source.
>>This SF.Net email is sponsored by xPML, a groundbreaking scripting
>>that extends applications into web and mobile media. Attend the live
>>and join the prime developer group breaking into this new coding
>>Jython-users mailing list