How can I run java code that has been pasted into my program
I'm making a simulator for Time Complexity. The purpose is that Students can choose which algorithms they want to compare.
But I want to make it possible to compare algorithms they've written themselves. I know how to get it to work with a compiled .class file.
I was wondering whether it is possible for the students to just paste the code (with predefined public methods) and then just run it.
I suppose that I have to do something with javac开发者_运维知识库.
Any ideas are welcome!
Thanks
Use the JavaCompiler class. You will need to add tools.jar to your classpath if you don't already have it.
精彩评论