Python has an exec () method, is there such a thing in Java?

2 answers 2

No, python is an interpreted programming language, unlike java. In other words, in order to run the java code, you first need to compile it.

  • 2
    And let me ask you what prevents exec from compiling code on the fly? Especially Python exec does just that (bytecode is interpreted, not the source code). - andreymal

From the question it is not clear why working with java in interpretation mode.

Read about JavaCompiler . In certain cases it may help.