0

Does Java ecosystem have a library that allow to pass a String and evaluate and execute that code?

eval("String value = text.split(\",\")[0]")

There is something like this?

Paulo Mattos
  • 18,845
  • 10
  • 77
  • 85
Paulo Oliveira
  • 2,411
  • 1
  • 31
  • 47
  • 3
    https://docs.oracle.com/javase/9/docs/api/jdk/jshell/package-summary.html – shmosel Feb 28 '19 at 00:17
  • The JShell tool – Slaw Feb 28 '19 at 00:17
  • BeanShell might be another option (but haven’t used it for a while now): https://github.com/beanshell/beanshell – Paulo Mattos Feb 28 '19 at 00:18
  • @shmosel @Slaw the `JShell` allows to use imported classes? – Paulo Oliveira Feb 28 '19 at 00:21
  • 1
    Yes, you can import classes. See https://docs.oracle.com/en/java/javase/11/jshell/external-code.html#GUID-D0BED087-AD44-4048-B37D-054308C64390 – Slaw Feb 28 '19 at 00:25
  • Also see https://stackoverflow.com/questions/46399783/is-there-a-way-to-modify-module-path-and-added-modules-of-a-programmatic-jshell if you're more interested in using JShell programmatically. – Slaw Feb 28 '19 at 00:32

0 Answers0