This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes evaluating string expressions in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "evaluating string expressions in Java" Watch "evaluating string expressions in Java" New topic
Author

evaluating string expressions in Java

Yatharth Kumar
Greenhorn

Joined: Dec 06, 2002
Posts: 14
All,
I am looking at usage of javascript eval method from within a java application to evlauate javascript expressions. Its works with JSObject, but the problem is I cant figure out how to obtain an instance of JSObject from a Java Class which is not an applet.
I dont want to use anything that will increase the size of the app. by more than 10 KB - why should I include complete JS engine if I all I want to do is eval!
Any help would be greatly appreciated !
thanks,
Y
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
There is nothing of the kind in the Java platform itself. You could write an expression evaluator yourself, or hunt down one that fits the bill; there are plenty around, varying from simple and small ones that consist of a single java file to complete scripting languages such as JavaScript, BeanShell, Jython or JRuby; see Programming Languages for the Java VM for more details than you ever wanted to know.
- Peter
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: evaluating string expressions in Java
 
Similar Threads
Escape XML special characters?
Check for existance of JSObject document
JSObject and Security
include Netscape package in CLASSPATH
Why to use eval function inside Javascript