Thanks Rony for replying. I did the changes but still getting the
following exception. Do I have to configure (provide path) to some log
file somewhere?

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/logging/LogFactory
        at org.apache.bsf.BSFManager.<init>(BSFManager.java:102)
        at EvaluatorB.Evaluate(EvaluatorB.java:13)
        at Evaluator.main(Evaluator.java:8)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.logging.LogFactory
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 3 more

Below is my program

import org.apache.*;
import org.apache.bsf.*;

public class EvaluatorB {

        public EvaluatorB()
        {
        }
        
        public Object Evaluate(){
                
                Object o = null;
                try{
                        BSFManager manager = new
org.apache.bsf.BSFManager();
                        o = manager.eval("java","",0,0,"return
(2==2);");
                }
                catch(BSFException exc)
                {
                        String s = exc.toString();
                        System.out.println(s);
                }
                return o;
        }
}



-----Original Message-----
From: Rony G. Flatscher [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 15, 2008 3:57 AM
To: Bean Scripting Framework users
Subject: Re: evaluating simple string "2 == 2"

Hi Raza,

also, make sure that the Java statement is syntactically correct.

In your example you obviously want to execute the following Java
statement: "return (2==2);". Hence your eval invocation should probably
read:

        Object o = manager.eval("java","",0,0,"return (2==2);");

HTH,

---rony


Raza, Rizwan (MLCI) wrote:
> Hi folks:
>
>  
>
> How can I evaluate the string "2 == 2" in a java program. Is it
> possible?
>
>  
>
> I did the following but it is throwing ClassNotFound exception
>
>  
>
> BSFManager manager = new org.apache.bsf.BSFManager();
>
> Object o = manager.eval("","",0,0,"2==2");
>
> return o.toString();
>
>  
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/logging/LogFactory
>
>       at org.apache.bsf.BSFManager.<init>(BSFManager.java:102)
>
>       at EvaluatorB.Evaluate(EvaluatorB.java:13)
>
>       at Evaluator.main(Evaluator.java:8)
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.logging.LogFactory
>
>       at java.net.URLClassLoader$1.run(Unknown Source)
>
>       at java.security.AccessController.doPrivileged(Native Method)
>
>       at java.net.URLClassLoader.findClass(Unknown Source)
>
>       at java.lang.ClassLoader.loadClass(Unknown Source)
>
>       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>
>       at java.lang.ClassLoader.loadClass(Unknown Source)
>
>       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>
>       ... 3 more
>
>  
>
> I think I am missing some configuration file. Can someone please point
> me to the right direction?
>
>  
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------

This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.
--------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to