Determining if plugin was launched from IDEA itself during plugin development


I know I can use PlatformUtils to determine which product is running, but how do I tell if I'm running from a copy of IDEA that was launched by IDEA itself during plugin development. i.e. I'm currently developing my plugin, regardless of which platform it is running.


You can pass specific jvm option in debug environment and check it with System.getProperty.
For example: `-Didea.debug.mode=true`.


If you want to do what Aleksey just said and you use Gradle for your build, you will want to add the following to your `runIde` task:

/* Propagate VM options from gradle command line through to the plugin. */
systemProperties = System.getProperties()

Otherwise, Gradle gets the options, instead of the secondary instance.  Just as a matter of course, I would stay away from the "idea" namespace for properties that you set for your own benefit.

If it's just for your local development, you could also check `PathManager.getHomePath()` for the location the instance is running from.  In the secondary instance, you will get the sandbox directory.  You obviously wouldn't want to ship something like that.


Thanks this helps. I realized I also need to detect the equivalent of a debug flag from another process. Is the best way to do that to look for a "java.exe" process (other platforms use another name like "idea64.exe") or is there a cleaner way? Is there some way to detect the package/bundle name such as "com.jetbrains.intellij" or "com.jetbrains.intellij-EAP"? I've seen closed source implementations that get this value on OSX, but I'm on Windows.


Please sign in to leave a comment.