Java: Load class from string

后端 未结 4 2120
粉色の甜心
粉色の甜心 2020-12-18 16:09

I know this has probably something to do with class loaders, however I couldn\'t find an example (it might be I\'m google-ing for the wrong keywords.

I am trying to

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 16:46

    At first you need to compile your code, for example using compiler API: ( http://www.accordess.com/wpblog/an-overview-of-java-compilation-api-jsr-199/, http://docs.oracle.com/javase/6/docs/api/javax/tools/package-summary.html). And after it load compiled class with ClassLoader ( http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/ClassLoader.html )

提交回复
热议问题