I already figured it out. With this snippet it is working: private static final JexlEngine ENGINE; static { Map<String, Object> fnc = new HashMap<>(); fnc.put("math", Math.class); ENGINE = new JexlBuilder().namespaces(fnc).cache(512).strict(true).silent(false).create(); }
And BTW, You are not importing anything from java.lang. It is already there by default. Gary Greenberg Staff Software Engineer Data Product Development, BI-A E: ggree...@visa.com M: 650-269-7902 -----Original Message----- From: Joakim Knudsen <joakim.gr...@gmail.com> Sent: Sunday, April 19, 2020 9:38 PM To: Commons Users List <user@commons.apache.org> Subject: Re: [jexl] How to use math functions with JEXL Hi, Did you import the Math library? import java.lang.Math; Joakim søn. 19. apr. 2020, 07:21 skrev Greenberg, Gary <ggree...@visa.com.invalid>: > I am trying to evaluate an expression that beside simple arithmetic > need to calculate square root. > > I tried sqrt(), Math.sqrt() and java.lang.Math.sqrt and nothing works > > I am always getting something like @1:1 undefined variable java.lang.Math. > > I did use before expr4j and it has all these functions built-in. > > Switched to JEXL, because need not only numeric, but also Boolean > expressions. > > Can you also confirm if this type of expressions will work: > > a.equalsIgnoreCase(“XYZ”) && b.startWith(“http”) > > where a and b are variables in the JexlContext. > > > > Gary Greenberg > > Staff Software Engineer > > Data Product Development, BI-A > > E: ggree...@visa.com > > M: 650-269-7902 > > > > [image: EmailSig-TaglineVersion] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org