How to launch an external process with a plugin jar?


Is there any way to pack an executable file into the plugin package?

Putting the executable file in PATH  is an awful  way . Any other solutions ?


It's possible to pack your executable into zip with your jar. And when installed they will be near each other.

Here is a working example with gradle:



I tried to put the executable file manually near the plugin jar and install the plugin package in OS X (Pycharm) .

But  it turns out  not able to find the executable file by the  plugin jar .

I print the user dir as :

System.getProperty("user.dir")  ,

it returns :


while the installed plugin location is : 

~/Library/Application Support/PyCharmCE2018.2 /xxxxx_plugin

So I try to get the jar path as:

String jarPath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().

but failed with a nullpointerexception.

Is there a way to get the plugin jar path in the code ? 




You can use com.intellij.openapi.application.PathManager.getJarPathForClass to get path to the containing JAR file.


Thanks ,  I just found this API   com.intellij.openapi.application.PathManager and everything works fine.

Just one trick,  all files in the installed plugin directory is set to  -rw-r--r--  , so I have to do chmod +x operation in  code.



Please sign in to leave a comment.