Skip to main content

Java Reloading classes many times

No replies
Joined: 2013-12-11
Points: 0

Hello everyone,

I have a problem in loading classes with the method of the classloader of java.

public class extends ClassLoader {MyClassLoader

     public MyClassLoader () {
         super (MyClassLoader.class.getClassLoader ());
     public void execPrg (String progname) {

         cls = super.loadClass (progname);

         Constructor constructor = cls.getConstructor (String.class, String.class);
Application app = (Application) constructor.newInstance (arg1, arg2);

         mytabbedpane.addTab ("Program", app);

The class is loaded correctly, the only problem is that they are allocated 2MB RAM every time you launch the method "newInstance ()"

There is a solution to make sure that the class is reused without reloading the memory?

Greetings and thanks.