Best approach to handle "custom" (unknown) Java class
<p>I am implementing kind of an online programming competition in and for Java. The idea is that a participant of the competition writes a controller for the application and sends it to the competition server. That custom controller has to be derived from an API's base class.</p>

<p>Ok, so all participants can write their own controller class, probabily also including other custom classes, and since the controller's main class is derived from an API's (abstract) base class, the application on the server can easily call a specific method of the child class (i.e. the custom controller) in a certain intervall in order to control the application.</p>

<p>My question now is: do you have any suggestions how I should handle this scenario from the API's perspective, so that it allows for a convenient way to dynamically load the custom controller implementation?</p>

<p>What I want to avoid is that the participants would need to include the API jar file into their Java project (e.g. in Eclipse), then write their controller class, put all into an executable jar again and upload it to the competition server. I definitely do not want to execute a fully custom application on the server.</p>

<p>I rather want to let the participants upload only their custom controller class. Then on the server this class should be automatically loaded in and as part of the application. I basically see two options here:</p>

<ol>
<li>upload compiled .class file to the server; or</li>
<li>upload Java source code file, then compile on server</li>
</ol>

<p>Which of these two options would you suggest, and why?<br>
Or: do you have another, better alternative?</p>

<p>Moreover, how should I handle uploads of multiple classes? If possible I would like to allow the participants to write additional utility classes beside the main controller class.</p>

<p>Thanks in advance for all your ideas!</p>
