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.

3
  • 1
    Please search before posting (or point out why existing answers aren't applicable) - stackoverflow.com/questions/588242/… Commented Mar 6, 2016 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. Commented Mar 6, 2016 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". Commented Mar 6, 2016 at 23:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.