Help compiling code dynamically
I'm not sure if what I'm trying to do is possible. This is a university project I'm trying to come up with, but I need some advice on where to go from here.
I'm building a website that will have a few basic OOP lessons with exercises the user has to solve. As for the language used in these exercises, I'm using java (of course).
My website will have a java applet with a textarea, where the user will be able to type their solution to the exercise.
That is all set and working already, but now I need to take the code written by the user and try to compile it, so I can tell the user if what they wrote is correct. This is where I need help: I'm guessing the best way to go is to generate a .java file containing the text the user wrote in the textarea of my applet, and then try to compile it into a .class file and catch any compilation errors so I can tell the user what went wrong.
My first question would be: is that the right way to go? There's another option?
My second question is: how do I achieve this?
I'm open to any recommendations, articles you can link me to, or any information that could help me.
Thanks a lot!!