logo       

Re: Evals from Java: msg#00033

lang.jython.user

Subject: Re: Evals from Java

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 <kent37@xxxxxxx> wrote:

Jake Eakle wrote:

Hi all,
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:
http://www.jython.org/docs/embedding.html

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.

Kent



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jython-users mailing list
Jython-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/jython-users





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise