Running two IDEA instances with my plugin

Hi,

I would like to run two instances of my plugin, because the plugin communicates between two IDEA instances. It works when I

  • create duplicate intelliJ installations with seperate ~/.ideaIC* folders
  • duplicate code folders for each


This is OK, but it is annoying because I have to sync the two source folders manually.

So I tried to run two instances from one IntelliJ application and managed to start them by changing the "Project structure -> SDK -> Sandbox home" setting between starts. I am able to start the plugin in one instance, but as soon as I want to start it in the other, I get ClassLoaderExceptions:

ERROR 17:37:49,729 [AWT-EventQueue-0 13.1.2#IC-135.690, eap:false] (IdeaLogger.java:141) de/fu_berlin/inf/dpp/intellij/ui/util/SafeDialogUtils
java.lang.NoClassDefFoundError: de/fu_berlin/inf/dpp/intellij/ui/util/SafeDialogUtils
    at de.fu_berlin.inf.dpp.intellij.ui.actions.ConnectServerAction.run(ConnectServerAction.java:125)
    at de.fu_berlin.inf.dpp.intellij.ui.actions.core.SarosActionFactory.startAction(SarosActionFactory.java:97)
  (...)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: de.fu_berlin.inf.dpp.intellij.ui.util.SafeDialogUtils PluginClassLoader[de.fu_berlin.inf.dpp.intellij.1, 10.1.1]
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 46 more


Is there any way to start two IntellIJ plugin instances from one IntelliJ instance? Or should I stick to the duplication above?

Regards,
Holger

12 comments
Comment actions Permalink

Try to create a second project where you import a module from the original project, and make a new IJ SDK with a different sandbox folder.

0
Comment actions Permalink

That seems to work, thank you very much!  (With two instances started from two different IDEA instances, but one source folder)


0
Comment actions Permalink

You should be able to start two instances from two different projects (from one IDEA instance).

0
Comment actions Permalink

I have some difficulty with the IDEA terminology now, I always thought only 1 project could be open in 1 instance. What do you mean by one IDEA instance?

  * One IDEA windows with two projects
  * Two IDEA windows with one project each, started from the same IDEA installation
  * Two IDEA instances, started from two different installations

0
Comment actions Permalink

One IDEA window can contain only one project.
One instance can open multiple projects/windows.
To open a second instance, you need a different installation directory and different .IntelliJIdeaXX folder.

0
Comment actions Permalink

When I do that I always get a

Process finished with exit code 3


Howver starting two instances (from two installations) probably is OK for testing.

0
Comment actions Permalink

Thank you very much for the video. This way one source directory is shared.
(in case the video is put offline, he creates a new projects, import the module by importing the .iml and creates a new project SDK in the new project, pointing to a different sandbox)

Howeber, when I do as you do, (importing the module so that they share one .iml), changing the Project SDK in one module always changes it in the other module too! Doesn't that happen to you too?

I could only fix it by starting two instances again (from two different directories) :S

0
Comment actions Permalink

No, the module should have "Project SDK" set, if you are setting a specific SDK to the module and not to the project, then it won't work.

0
Comment actions Permalink

I had that -- the module has project SDK set. But when I change the project SDK in one instance, it is also changed in the other. This was not the case in your setup, right?

0
Comment actions Permalink

Right. For example when I change the project SDK to plain Java SDK so that it cannot be compiled, then the other project is totally fine.

If you look into the .iml file, there should be:

 
<orderEntry type="inheritedJdk" />
0
Comment actions Permalink

Well who knows what happened there, I tried it again and it worked perfectly. For the sake of posterity, in case the video is taken down again (thanks again for creating that, it was really helpful!).

  • Set your plugin module SDK to project SDK and your project SDK to IDEA SDK
  • Create a new project, import your module
  • In my case, create libraries with exactly the same name in your new project, to satisfy module dependencies  (in the project settings dialog)
    • they have to have exactly the same name, otherwise you will modify the original project files and end up in cascading-change hell
  • Create a new IDEA SDK (e.g. "IDEA SDK 2" and change the "sandbox home" folder in Project Settings -> SDK -> IDEA SDK (2) to another folder (e.g. "plugin-sandbox2")
  • Set your new project's project SDK to "IDEA SDK 2"


This way the module settings can stay the same across both projects (Module SDK is project SDK, all libraries have the same name) and only the project settings, that reside in the new project's folder are changed.

0

Please sign in to leave a comment.