Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:16:42+00:00 2026-05-15T17:16:42+00:00

I am doing rnd for JEXL but i got exception for the below program;

  • 0

I am doing rnd for JEXL but i got exception for the below program;

        String strDuration = "4560";
        long lDuration = Long.parseLong(strDuration);
        String theExpression = "" +
                "if(lDuration > 500)" +
                "   return true;" +
                "else" +
                "   return false;";

        Expression e =  jexl.createExpression( theExpression );
        JexlContext context = new MapContext();
        context.set("lDuration", lDuration);
        Boolean result =(Boolean) e.evaluate(context);
        System.out.println("The answer : " + result);

Exception :
Caused by: org.apache.commons.jexl2.parser.ParseException: Ambiguous statement @1:30, missing ‘;’ between expressions

Can anyone help me to display the output that i want(the boolean)?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:16:42+00:00Added an answer on May 15, 2026 at 5:16 pm

    Here you go:

      public static void main(String[] args) {
        String strDuration = "4560";
        long lDuration = Long.parseLong(strDuration);
        String theExpression = "(lDuration > 500) ? true : false;";
        JexlEngine jexl = new JexlEngine();
        Expression e = jexl.createExpression(theExpression);
        JexlContext context = new MapContext();
        context.set("lDuration", lDuration);
        Boolean result = (Boolean) e.evaluate(context);
        System.out.println("The answer : " + result);
      }
    

    Edit:
    To be clear the problem is your use of the return statement, it appears to not be supported by JEXL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing the below will reproduce my problem: New WPF Project Add ListView Name the
When doing case-insensitive comparisons, is it more efficient to convert the string to upper
What am I doing wrong here? return listBoxKeywords.Items[rnd.Next(0, listBoxKeywords.Items.Count)].ToString(); I get the following error:
I am doing some RnD work, looking forward for experts suggestion: I have to
I am doing some RND for android and google cloud. Did some research on
I've got a drupal site that gets low traffic, but has tons of new
Doing some integration work with another site I've got the unusual requirement of needing
Doing a Socket.Receive(byte[]) will get the bytes in from the buffer, but if the
Doing some javascript self-learning and the program itself is very simple. It searches through
Doing some testing but cannot fabricate debug environment so maybe someone can answer this.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.