0

I want user to be able to input a snippet of code with a class or function implemented in Java and the program should run this code, without referring to external tools like javac or saving class files to fisk.

In Clojure it is clear, as there is read and eval. Can it be done for a plain Java code, possibly with some third party jar?

The code is expected to be some variables, some loops, some mathematical functions and maybe some calls to the framework that is running it.

Vi.
  • 37,014
  • 18
  • 93
  • 148
  • 1
    Please search before posting (or point out why existing answers aren't applicable) - http://stackoverflow.com/questions/588242/how-could-i-call-java-code-dynamically – Oliver Charlesworth Mar 06 '16 at 23:28
  • Java has built in JavaScript engines, if you are ok with using snipits of JavaScript, instead of Java. The JavaScript can even create/reference/use Java objects. – AJNeufeld Mar 06 '16 at 23:33
  • @OliverCharlesworth, I've searched for things like "java eval" and found similar quesiton about Scala. Suggested questions also didn't show something directly relevant. Also "to call java code dynamically" may be not ideally titled: my first though it that it is about "how do I load jar file in runtime, like with dlopen/loadLibrary for C libraries". – Vi. Mar 06 '16 at 23:54

0 Answers0