classloader in plugin

Hi,
I am beginner with the plugin development and
I have the following problem with the ClassLoader: I want to load a class from an arbitrary directory in plugin's runtime but it is not working - ClassNotFound exception is thrown. however, everything works if I do the same in the simple java application.
please, help me!!!

0
6 comments

Why do you need to do this? I think you should create directory named lib immediately inside your plugins directory. Any jar files put here can be used from your plugin without further configuration.

Regards
Frank Bruch

0

Thanks very much for the feedback.
I need this for the following reasons. I want to change implementation of one class and force my plugin to use it during runtime. After changing this class IDEA should compile it and then plugin should use this new class. Of course, i do not want to restart IDEA everytime i change this class. How should I do it?

0

Hello iLia,

i> Thanks very much for the feedback.
i> I need this for the following reasons. I want to change
i> implementation of one class and force my plugin to use it during
i> runtime. After changing this class IDEA should compile it and then
i> plugin should use this new class. Of course, i do not want to restart
i> IDEA everytime i change this class. How should I do it?

If I understand you correctly, what you actually need is hot swap, not a
custom classloader.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

thank you,
yes, it seems to be very usefull for my problem. so where should I look for first time to get info how to use it?

0

Hello iLia,

i> thank you,
i> yes, it seems to be very usefull for my problem. so where should I
i> look for first time to get info how to use it?

You don't need anything special for that. You just need to run the IDEA instance
with your plugin under the debugger from another IDEA instance, and ensure
that the option "Reload classes after compilation" in the IDEA debugger settings
is set to "Always" or "Ask". When you change the code and make it in the
development instance of IDEA, it'll reload the changed classes into the running
instance.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

thank you very much
I will use it.
however I have the question - I get ClassNotFound exception in the code like this:

Plugin - {
ClassLoader c = new URLClassLoader(url);
c.loadClass(]]>);
}
it is not work but if I run this code from simple main function - Ok! Can you explain me the problem?

0

Please sign in to leave a comment.