How to run Java code using Java code?

后端 未结 4 1520
北荒
北荒 2020-12-05 22:35

Basically, I want to do two things:

  1. I want to know if there is any way that I can run Java code using Java code.
  2. If it is possible, how would I show t
4条回答
  •  余生分开走
    2020-12-05 22:58

    You would have to some how invoke a compiler (such as Suns javac), parse its output in case of errors and load the resulting classes dynamically.

    There is no API-classes in the Java runtime library that will parse, compile and run Java source code.

提交回复
热议问题