Why IntelliJ Maven uses jre, not jdk

Answered

I entered "mvn -version" in the IntelliJ teminal, but it kept showing jre, not jdk as my system environment set. How to change that?

7 comments
Comment actions Permalink

Duplicating my reply to you for the same support request:

IDE terminal uses the same environment as OS terminal. What result do you get in OS terminal?

See https://stackoverflow.com/a/19654699/2000323 how to set Java for command line maven.

 

For the Maven in IDE you configure it in
- Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Importing | JDK for importer - for importer process
- Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Runner | JRE - for executing maven goals from IDE (e.g. in Maven tool window).

0
Comment actions Permalink

Under Windows command line, it shows JAVA_HOME=C:\Java\jdk1.8.0_231, and mvn -verison showed "Java home : C:\Java\jdk1.8.0_231\jre". However, in IntelliJ terminal, the mvn -version still showed "Java home: C:\Java\jre8u231_x64". That's why I don't understand where I went wrong.

0
Comment actions Permalink

Does IDE restart help (or if you use Toolbox App for installing and running IDE - restart the Toolbox App, then start the IDE)? Do you check the environment for the same user in OS terminal and IDE terminal?

Check that you use same shell in OS terminal (e.g. cmd.exe) and in IDE: Settings (Preferences on macOS) | Tools | Terminal | Shell path. Also check that you did not re-defined anything in Terminal | Project settings | Environment Variables settings.

0
Comment actions Permalink

The strange part is that I invalidate cache and restart several times. The result is the same. I also checked the settings of terminal, it said cmd.exe. I can't do nothing about it. Please kindly advise.

0
Comment actions Permalink

Do you use Toolbox App?

What output you see for

echo %JAVA_HOME%

in IDE Terminal and in OS cmd.exe?

You can see what environment variables IDE inherits from the OS here:

0
Comment actions Permalink

I don't have Toolbox App. Unfortunately, echo %JAVA_Home% in IDE terminal is %JAVA_HOME%, while in OS cmd.exe is C:\Java\jdk1.8.0_231. I don't know why.

0
Comment actions Permalink

>Unfortunately, echo %JAVA_Home% in IDE terminal is %JAVA_HOME%

Do you mean this environment variable is not expanded in IDE terminal?

Do you see %JAVA_HOME% defined in the list of environment variables in Terminal settings as I have attached?

Please attach screenshot similar to mine where all Terminal options would be seen and idea.log (Help | Show Log in ... action) after IDE restart.

 

0

Please sign in to leave a comment.