Situation:
I'm making a simulator for plotting the time complexity of algorithms. The students can add load their own .java file to run it. My program compiles (with 'JavaCompiler') the .java file. Then it tries to load the .class file:
loadedClass = loadClass("customAlgorithms."+this.getClassName()+"");
When running my program in Eclipse, everything works fine, and students can use the program flawlessly.
Problem:
But then I export my project to an executable jar file. The compiling part still works but loading the class fails because it searches it inside the jar file.
I was wonderding why I couldn't just do this: (change . with /)
loadedClass = loadClass("customAlgorithms/"+this.getClassName()+"");
What options are possible? Here what I can think of:
adding the compiled .class file to the currently running .jar file. Can this even work?
I know it is possible to edit a jar archive. But can this work while running and without having to restart the program?
other way to use 'loadClass()' ? So that I can load a class file which is not included in my jar file
Are there other ideas?