SonarLint for IntelliJ: How to use a different JRE

  • Operating system: Windows 10
  • IntelliJ version: 2024.1.2
  • SonarLint plugin version: 10.6.2.78685

The SonarLint plugin seems to use the JRE used by IntelliJ (i.e. JBR with JCEF 17.x).
For some reason (don’t ask with) I can execute IntelliJ through its idea64.exe, but I am not allowed to execute the java.exe from that JBR directly.

This causes SonarLint to fail when IntelliJ is run with its JBR. However, when I change the “Boot Runtime for the IDE” to a JRE authorized by my company (e.g. zulu 17), SonarLint works fine.
The issue is now that IntelliJ lacks some features of its own JBR such as nice windows decoration and the ability to render previews for markdown of asciidoc files.

My question is then: How can I change the JRE used by SonarLint without changing the JRE used by Intelli?

Hi @Pigelvy,

Thanks for reaching out, and I’m sorry for the response taking so long. We already had an internal discussion about this.

Currently, you cannot change the Java runtime used by SonarLint as it listens to the java.home system property, that is set to the JBR or to whatever Java runtime IntelliJ itself is started with.

From what you described, I see the problem with your strict environment. This does not only affect SonarLint itself but also other plug-ins inside IntelliJ that will make use of it.
I cannot tell you why running IntelliJ itself with its own JBR works and why SonarLint doesn’t, but I’d advise you to reach out to your IT department about that.
Maybe this is not even intended and even your IntelliJ should only run with the company authorized Java runtime. But I have no clue and can only guess here.
You might also contact your IT to authorize the JBR (or another, standalone JBR) based on the benefits it brings to you and then (in theory) IntelliJ as well as SonarLint should work fine.

If this is not possible, please come back and reach out again so we can think about it again and possibly find another solution.

Best,
Tobias

Hi,

I won’t reach out to the IT department because it will start a multitude of useless conversations that will only pollute me with politics and decisions made by people that never work with JDKs and up-to-date IDEs.

As far as SonarLint is concerned, a simple thing would be to allow the user to specify which JRE to use. Just like the Maven integration allows us to choose a specific Java runtime.

Without this configuration, SonarLint would fallback to the Java runtime used by Intellij, as it does today.

Thanks for thinking about this. It is indeed a problem many plugins are confronted to but it should not prevent you from enhancing the situation :+1:

Regards and congrats for the good job.

1 Like

Hey @Pigelvy,

we decided that providing the user the option to set their own JRE just for SonarLint might be a good improvement for cases like yours. I created THIS ticket for it to be tackled sometime in July probably.

Best,
Tobias

Hi
It’s been 3 months and I noticed that this evolution was added to the Eclipse plugin. Very nice for the Eclipse community.
I, however, am more team IntelliJ and am kinda sad the related-issue, https://sonarsource.atlassian.net/browse/SLI-1472, is low priority.

Please, please, give us the possibility to choose the Java runtime too.

If I can be of any help to resolve that issue, let me know how.

Thx

1 Like

Hi @Pigelvy,

the ticket was tackled in the meantime. It should be available with the upcoming release of SonarLint for IntelliJ.

Best,
Tobias

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.