Home
Javaluator is a simple, but powerful, infix expression evaluator for Java.

Evaluating an expression is as simple as the following lines :

String expression = "(2^3-1)*sin(pi/4)/ln(pi^2)";
Double result = new DoubleEvaluator().evaluate(expression);


Key features:

  • Functions support: including variable number of arguments and functions with no argument.
  • Constants support: for example pi and e when evaluating expressions on doubles.
  • Variables support: Expressions can include variables (example "sin(x)").
  • Highly configurable: This library comes with some built-in functions and operators, it is very easy to reduce the number of them (for example, the trigonometric functions can be removed from the function set if you want to implement a financial calculator).
    It's also easy to define your own bracket pairs ({},[], etc ...) or to add your own operators, functions or constants.
  • Extensible: This library is provided with an evaluator that deals with expression on real numbers, if you need one on complex numbers, or on anything else, you can implement your own.
  • Localization: Function and constant's names can be changed easily
  • Expression syntax check: Basic infix evaluators consider expressions such as "4 3 +" as valid expressions. Javaluator performs a full syntax check while evaluating the expression.
  • Small footprint: This library is distributed as a 26kB jar. It needs no external library in order to run.
If you want to learn more on these features, please have a look at the tutorial.

Limitations:

  • Only unary and binary operators are supported (ternary operators such as condition?value if true:value if false are not).
  • Non-associative operators are not supported.


This library is available for free under LGPL v3 license.

Advertising

Back to top