ToolProvider. getSystemJavaCompiler() returns null in IntelliJ plugin


I am creating a plugin where i ask user to enter the java code int a TextArea.

I have created an Action for this and, when clicked on Action, i am able to show a dialog box with TextArea in it.

After the user has entered the code and click on “Ok” button, i am trying to compile the code.

I used ToolProvider.getSystemJavaCompiler() but it is returning null.


After googling a bit about the command you mentioned, I found this:

Essentially IntelliJ itself is running using a JRE, not a JDK. What you can do is check the SDKs used in the current project or module and use the JDK set there, however they could also be Python SDKs for example, so be cautious and check their types.


I solved it in my plugin, you can search Cool Request, or go to my github


Hi Bradan,

Thanks for the tip. I will try to get the current JDK of project and invoke javac from there.

Hi Hxl49508,

I checked your repository. it seems you are shipping a javac.jar along with your plugin. However i am not allowed to add any extra jar unless extremely necessary. Can you please confirm if i understood your project correctly and you are shipping an additional jar.



Yes, this is the only solution I've found so far


This javac.jar file is only 3M, very small


Please sign in to leave a comment.