Need reasonable message if user runs my plugin from the wrong IJ 2019 (JBR 8 instead of JBR 11)

I have a plugin that depends on running in IJ 2019 JBR 11.  Sometimes, my users accidentally start it under IJ 2019 JBR 8.  When they do, one of two things happen, depending on which operating system they are running:

1. On Windows, IntelliJ appears to exit silently if it detects a problem with Java 11 executables in a jbr8 environment.  Users wait for a long time, and try several times, and then report a "bug" that the IDE does not start up.

2. On Mac OS, IntelliJ pops up a modal window titled "JDK Required" that says "JDK classes seem to be not on IDEA classpath. Please ensure you run the IDE on JDK rather than JRE." The only response is "OK", which causes the code to exit the JVM. It is not clear that "OK" means "EXIT", and the root cause has nothing to do with the message displayed: they installed the wrong version of Idea.

Neither of these helps the user figure out the root cause.  I put in code in my plugin startup to display a more meaningful message but IJ exits before my plugin starts up.  I would suggest that on all operating systems, you pop up a modal window that tells the user he/she needs to run a different version of IJ.  Then offer the response "EXIT" instead of "OK", so the user understands what is happening.

5 comments
Comment actions Permalink

Could you please provide steps to reproduce the issue please? Thanks.

0
Comment actions Permalink

Easier said than done.  We created a plugin with lots of dependencies on Java 11 jars and we ourselves used Java 11 to build our plugin, and assume Java 11 modules, etc. We start the JVM with a classpath that is correct for Java 11.

Your class StartupUtil.java calls checkJdkVersion(), which tries to find an expected Java class using classForName().  However, we start the JVM associated with the installed Idea specifying a classpath that does not include tools.jar because we are expecting that we are starting a JBR11, and in Java 11, there is no such thing as tools.jar.  So checkJdkVersion() finds it cannot load the class "Field", and then gives the misleading error message I described above.  Your code is just guessing that the only reason the class Field is not found is that a JRE is being used.  That is only one possibility.

I appreciate that this problem is a combination of our classpath and your code. We tried to detect the problem in our plugin startup, but we never get there to check that the Idea is the correct one.  Basically, if our users install a JBR8 and have their environment variables pointing to it, our script starts the Java (Java 8) located in the JBR8 installation and then passes the classpath we need for JBR11.  

So you could probably reproduce this by starting Idea from the Java in JBR8, but passing it a classpath that is appropriate for JBR11 (i.e., does not include tools.jar) so that checkJdkVersion() will fail.  Then you can see what happens and try to refine the error message.

Also, on both Windows and Mac OS, your code should pop up a screen with the appropriate error message, and label the button "EXIT" instead of "OK".  Obviously, this is I18n and my suggestions are for English.

0
Comment actions Permalink

I am having a similar issue. Nothing I have tried has resolved the error, even reinstalling IJ.

0
Comment actions Permalink

What worked for me was to set an environment variable:

IDEA_JDK = %JAVA_HOME%

0
Comment actions Permalink

Then go into File->Project Structure->Project Settings->Project

...and set your SDK. You would think this was under File->Settings, but sadly it is not.

0

Please sign in to leave a comment.