title: Compile a .class file from a .txt file
body: <p>I am progamming a game in which the player navigates puzzles by changing the source code of objects within the levels themselves. In order to do this I have a class extending JPanel which is to be written over with the edited source code from the player.  My question is how can I compile a class file from a text file, either using java utilities or using beanshell? The text file contains pure java but the player of the game may cause compilation or runtime errors (such as infinite loops) and I want to be able to catch said errors and alert the player. </p>