最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Problem with using Intellij on windows to run a basic maven project on WSL: it only works using wsl terminal - Stack Over

programmeradmin2浏览0评论
  • This is a simple Maven project placed in WSL file system with a default Hello World main method class. I use Java 21 on Windows, and Java 8 on WSL.

4.0.0

    <groupId>wsl.testing</groupId>
    <artifactId>WSLTesting</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <mavenpiler.source>8</mavenpiler.source>
        <mavenpiler.target>8</mavenpiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
   <build>
       <plugins>
           <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>3.8.1</version>
               <configuration>
                   <source>1.8</source>
                   <target>1.8</target>
               </configuration>
           </plugin>
       </plugins>
   </build>

</project>

I have configured it to run on WSL in all possible places as shown in the screen shot and in other places. I set the JDK on the one I have in my Ubuntu machine. => It all boils down to Maven, then:
Regardless of the Maven home I use, if I DO NOT check "delegate IDE build/run to Maven"
I get the error:

Attempting to start build with JDK Java version "21.0.3+13", which is not stored in the project's WSL distribution. The JDK to run the build as well as JDK used by the project must be stored in the same WSL distribution where the project is stored. A JDK 11 or later is required to run the build. If your project uses older JDK, please add a JDK 11 or newer to your SDK configuration table. This JDK will be automatically picked up to run the build.

This happened when using Bundled Maven: And it also happens when using Maven installed on WSL:

When I delegate IDE build/run actions to Maven the result depends:

  • Using bundled Maven:
  • Using Ubuntu Maven:
  • Checking or unchecking seems irrelevant:

Using WSL terminal and native Maven works But that means the IDE is not that useful. mvn clean compile exec:java -Dexec.mainClass="wsl.testing.Main"

=> I would like to know how to solve this and know why there is a difference when checking

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论