简体   繁体   English

此环境中未提供编译器。 也许您在 JRE 而不是 JDK 上运行?

[英]No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

I'm compiling a project in Eclipse using m2eclipse.我正在使用 m2eclipse 在 Eclipse 编译一个项目。 I set the JDK path in Eclipse like this:我像这样在 Eclipse 中设置 JDK 路径:

Windows-->preferences-->installed jres--> jdk1.7.xx  path

But this is showing an error但这显示错误

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE    rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.424s
[INFO] Finished at: Tue Oct 29 15:21:01 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-   plugin:3.1:compile (default-compile) on project TEST-WEB: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
  1. On your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > and check your installed JREs .在您的 Eclipse IDE 上,进入Window > Preferences > Java > Installed JREs > 并检查您安装的 JREs You should have an entry with a JDK there.您应该在那里有一个带有 JDK 的条目。
  2. Select the Execution Env as show below.选择执行环境,如下所示。 Click OK单击确定
  3. Then Right-Click on your Project -> Maven -> Update Project然后右键单击您的项目 -> Maven ->更新项目

Additionally, you may have to change Maven JRE (see @jlars62 answer) which is as follows.此外,您可能需要更改 Maven JRE(请参阅 @jlars62 答案),如下所示。 Goto Run -> Run Configurations, selecting the Maven Build I was running (from the left panel).转到 Run -> Run Configurations,选择我正在运行的 Maven Build(从左侧面板)。 Then, I clicked the JRE tab and selected the option Workspace default JRE然后,我单击 JRE 选项卡并选择了选项 Workspace default JRE

在此处输入图片说明

For me, it is exactly what the maven of eclipse complains对我来说,这正是 eclipse 的专家抱怨的

在此处输入图片说明

So, I press Edit button and change path to the JDK Folder, then clean project and everything starts to work所以,我按Edit按钮并更改 JDK 文件夹的路径,然后清理项目,一切开始工作

  1. Set the JAVA_HOME environment variable to the JDK root folder - required if you run command line or maven ( mvn ).JAVA_HOME环境变量设置为 JDK 根文件夹 - 如果您运行命令行或 maven ( mvn ),则这是必需的。
    • (Search google for JAVA_HOME for more info) (在谷歌搜索JAVA_HOME了解更多信息)
  2. In project properties in section Java Compiler select required JDK - if you run directly from eclipse在 Java Compiler 部分的项目属性中选择所需的 JDK - 如果您直接从 eclipse 运行

For me, nothing worked until I made this change to my pom.xml:对我来说,在我对 pom.xml 进行更改之前,什么都不起作用:

<build>
...
    <plugins>
    ...
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

Other Notes其他注意事项

I could see that m2e was executing in a JRE, not the JDK.我可以看到 m2e 在 JRE 中执行,而不是在 JDK 中执行。 Nothing I did changed this, including adding this to the eclipse.ini:我没有做任何改变,包括将它添加到 eclipse.ini:

-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe

In the end I never got m2e to execute in a JDK, but setting the Java compiler explicitly (as above) did the trick.最后,我从来没有让 m2e 在 JDK 中执行,但是显式设置 Java 编译器(如上所述)可以解决问题。

In my case it was solved by doing this:在我的情况下,它是通过这样做解决的:

Go to your 'Runtime Configuration' and configure your JRE to an JDK.转到您的“运行时配置”并将您的 JRE 配置为 JDK。

为您的运行时选择正确的 JDK

选择默认 JRE

I copied answer just in case it is deleted for some reason, but the source is here我复制了答案以防万一它因某种原因被删除,但来源在这里

I was getting this error when trying to do a maven build from within eclipse.尝试从 Eclipse 中进行 Maven 构建时出现此错误。

For me, the answer was going to Run -> Run Configurations , selecting the Maven Build I was running (from the left panel).对我来说,答案是Run -> Run Configurations ,选择我正在运行的Maven Build (从左侧面板)。 Then, I clicked the JRE tab and selected the option Workspace default JRE然后,我单击JRE选项卡并选择了选项Workspace default JRE

Go to windows -> Preferences -> Java -> Installed JREs转到 Windows -> 首选项 -> Java -> 已安装的 JRE

may be jre is already added可能是 jre 已经添加了在此处输入图片说明

click on Add -> Standard VM -> Next -> Directory点击添加 -> 标准虚拟机 -> 下一步 -> 目录

and browse for the JDK in my case path was C:\\Program Files\\Java\\jdk1.8.0_111并在我的案例中浏览 JDK 路径是C:\\Program Files\\Java\\jdk1.8.0_111

then Click on finish.然后点击完成。

you will see window like this你会看到这样的窗口在此处输入图片说明

select JDK -> Apply -> Ok选择 JDK -> 应用 -> 确定

And You are done.你已经完成了。

I got same issue and i just add JAVA_HOME to environment variables .我遇到了同样的问题,我只是将JAVA_HOME添加到环境变量中

环境变量

  • If you are using eclipse, just refer https://stackoverflow.com/a/21279068/6097074如果您使用的是 Eclipse,请参考https://stackoverflow.com/a/21279068/6097074
  • If you are using intellij, just after adding JAVA_HOME open command prompt from project directory and run mvn clean install (don't use intellij terminal).如果您使用的是 intellij,只需在添加JAVA_HOME后从项目目录打开命令提示符并运行mvn clean install (不要使用 intellij 终端)。

I tried all of the above, however, still getting the same error message.但是,我尝试了上述所有方法,仍然收到相同的错误消息。

In my case an actual JRE was incorrectly used as JRE System Library in the project-specific build path which was obviously overriding all those other settings discussed here.在我的例子中,一个实际的 JRE 在项目特定的构建路径中被错误地用作 JRE 系统库,这显然覆盖了这里讨论的所有其他设置。

If that is so in your case try the following:如果您的情况是这样,请尝试以下操作:

  1. Open the project-specific libraries of the Java Build Path: Right-click "Project > Build Path > Configure Build Path..." and select "Libraries" tab.打开Java Build Path的项目专用库:右键“Project > Build Path > Configure Build Path...”,选择“Libraries”选项卡。
  2. Select the "JRE System Library" entry and hit "Remove".选择“JRE 系统库”条目并点击“删除”。
  3. Hit "Add Library...".点击“添加库...”。
  4. A wizard pops up.弹出一个向导。 Select "JRE System Library" and hit "Next >".选择“JRE 系统库”并点击“下一步 >”。
  5. Now select the correct JDK (in my case "Workspace default JRE", which I configured using a JDK).现在选择正确的 JDK(在我的例子中是“Workspace default JRE”,这是我使用 JDK 配置的)。
  6. Close wizard by hitting "Finish".点击“完成”关闭向导。
  7. Close "Properties" dialog by hitting "OK".点击“确定”关闭“属性”对话框。

An alternative if jaipster's answer does not work is to go to:如果 jaipster 的答案不起作用,另一种方法是转到:
Window > Preferences > Java > Installed JREs窗口 > 首选项 > Java > 已安装的 JRE

Then to edit the jre so that it points to the jdk and not the jre (the jre home filed in the jre package editor)然后编辑 jre,使其指向 jdk 而不是 jre(在 jre 包编辑器中归档的 jre home)

That worked for me.那对我有用。

If you are running the Maven command from cmd , make sure you set the jdk path before running the command.如果您从cmd运行Maven命令,请确保在运行该命令之前设置 jdk 路径。 In my case, I have created a .bat file containing the following:就我而言,我创建了一个包含以下内容的.bat文件:

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
start cmd.exe /k "cd c:\aem_proj\sis\aau"

I faced the same issue while trying to build a jar file of my project application using mvn clean install , though the application was working fine while running from Eclipse.我在尝试使用mvn clean install构建我的项目应用程序的 jar 文件时遇到了同样的问题,尽管该应用程序在从 Eclipse 运行时运行良好。

The issue was, indeed too naive, that I had not set the JAVA_HOME environment variable.问题是,确实太天真了,我没有设置JAVA_HOME环境变量。 All I had to do is set JAVA_HOME environment variable to JDK directory, make sure it is not till "\\bin" and without semi-colon ";"我所要做的就是将 JAVA_HOME 环境变量设置为 JDK 目录,确保它不是直到“\\bin”并且没有分号“;” . .

在此处输入图片说明

How I understood it is as:我的理解是这样的:

The application worked fine in Eclipse as JRE System Library was referring to JRE inside the JDK folder instead of external JRE folder without JDK.该应用程序在Eclipse工作细如JRE系统库指的是JRE的JDK文件夹,而不是外部JRE文件夹中没有JDK里面 [As explained very well in other answers] [正如在其他答案中很好地解释的那样]

This configuration does not apply to maven command that we run on command prompt.此配置不适用于我们在命令提示符下运行的maven命令。 It will still look for JAVA_HOME variable to access the JRE System library and when it is not found it refers to external JRE folder without JDK.它仍然会寻找 JAVA_HOME 变量来访问 JRE 系统库,当找不到它时,它指的是没有 JDK 的外部 JRE 文件夹。

My answer pertains to the Eclipse in Windows environment.我的回答与 Windows 环境中的 Eclipse 有关。

I went to Preferences --> Java --> Installed JREs I did NOT see the JDK in here.我去了首选项 --> Java --> 安装的 JRE 我在这里没有看到 JDK。 I only saw the JRE here.我只在这里看到了 JRE。 So I added the JDK and then unchecked the JRE.所以我添加了JDK,然后取消选中JRE。 Then checked JDK.然后检查JDK。 Then I ran the POM file using Run Configurations.然后我使用运行配置运行 POM 文件。 Choose the tab JRE and select the option "Workspace Default..." Here are the images选择选项卡 JRE 并选择选项“工作区默认...”这是图像

在此处输入图片说明

在此处输入图片说明

There are several options to specify.有几个选项可以指定。

Steps: Right on project in project explorer Go to Run-> Run Configuration -> Click Maven Build -> Click on your build config/or create a new config.步骤:在项目资源管理器中的项目上转到运行-> 运行配置-> 单击 Maven 构建-> 单击您的构建配置/或创建一个新配置。 You will see the window as the given snapshot below, click on JRE tab there.您将看到作为下面给定快照的窗口,单击那里的 JRE 选项卡。

You see you have 3 options 1) Workspace Default JRE 2)Execution Environment 3)Alternate JRE您会看到有 3 个选项 1) 工作区默认 JRE 2) 执行环境 3) 备用 JRE 在此处输入图片说明 1) Workspace Default JRE is set from 'Window' menu on the top -> Preferences -> Java -> Installed JREs -Here you can add your jdk 1) 工作区默认 JRE 是从顶部的“窗口”菜单设置的 -> 首选项 -> Java -> 已安装的 JRE - 在这里您可以添加您的 jdk 在此处输入图片说明 2) Execution Environment jdk can be set in pom.xml as mentioned by @ksnortum 2)执行环境jdk可以在@ksnortum提到的pom.xml中设置

<build>
<plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <fork>true</fork>
            <executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
        </configuration>
    </plugin>
</plugins>

3) Alternate JRE can be used to select a jdk from your directory 3) 替代 JRE 可用于从您的目录中选择一个 jdk

Problem statement = No compiler is provided in this environment.问题陈述= 此环境中未提供编译器。 Perhaps you are running on a JRE rather than a JDK?也许您在 JRE 而不是 JDK 上运行? intellij智能

Solution解决方案

Please set the Environment variabl e like below to solve the issue请像下面这样设置环境变量来解决问题

Variable name : JAVA_HOME变量名:JAVA_HOME

Variable Value : C:\\Program Files\\Java\\jdk1.8.0_202变量值:C:\\Program Files\\Java\\jdk1.8.0_202

Variable name : M2_HOME变量名:M2_HOME

Variable Value : C:\\Program Files\\apache-maven-3.6.0变量值:C:\\Program Files\\apache-maven-3.6.0

Moreover , Add Java and maven path in " System Variables " like below:此外,在“系统变量”中添加 Java 和 maven 路径,如下所示:

  1. C:\\Program Files\\Java\\jdk1.8.0_202\\bin C:\\Program Files\\Java\\jdk1.8.0_202\\bin

  2. C:\\Program Files\\apache-maven-3.6.0\\bin C:\\Program Files\\apache-maven-3.6.0\\bin

Though the question is about the error with Eclipse setup but thought an answer of fixing this error with IntelliJ and Windows 10 setup may also be helpful here.虽然问题是关于Eclipse设置的错误,但认为使用IntelliJ和 Windows 10 设置修复此错误的答案在这里也可能有所帮助。

1 . 1 . Go to File --> Settings --> Build, Execution, Deployment --> Build Tools --> Maven --> Importing转到File --> Settings --> Build, Execution, Deployment --> Build Tools --> Maven --> Importing

2 . 2 . Set JDK for Importer as shown below to JAVA_HOME如下图设置Importer JDKJAVA_HOME

在此处输入图片说明

Also JAVA_HOME should be set to JDK path at Environment Variables --> System variables and also add %JAVA_HOME%\\bin to Path System variables此外, JAVA_HOME应该在 Environment Variables --> System variables 中设置为JDK路径,并将%JAVA_HOME%\\bin添加到路径系统变量

For me the JRE was in the PATH environment variable before the JDK path对我来说,JRE 在 JDK 路径之前位于 PATH 环境变量中

  1. C:\\ProgramData\\Oracle\\Java\\javapath C:\\ProgramData\\Oracle\\Java\\javapath
  2. C:\\env\\jdk1.8.0_151\\bin C:\\env\\jdk1.8.0_151\\bin

So I removed 1. Probably swapping them would fix it too.所以我删除了 1. 可能交换它们也会修复它。

There is another possible answer to this question, and I may be the only person foolish enough to have stumbled upon this, but I think it's worth adding, since none of the other answers applied as I already had those settings correct.这个问题还有另一个可能的答案,我可能是唯一一个愚蠢到偶然发现这个问题的人,但我认为值得补充,因为没有其他答案适用,因为我已经正确设置了这些设置。

When you install a JDK, the installer asks you where you want to install the files.安装 JDK 时,安装程​​序会询问您要将文件安装到何处。 By default, on Windows, this is something like C:\\Program Files\\Java\\jdk1.8.0_74 (or whatever version you are installing).默认情况下,在 Windows 上,这类似于 C:\\Program Files\\Java\\jdk1.8.0_74(或您正在安装的任何版本)。

It then asks you for a directory to install the JRE to, which by default is something like C:\\Program Files\\Java\\jre1.8.0_74.然后它会要求您提供一个用于安装 JRE 的目录,默认情况下该目录类似于 C:\\Program Files\\Java\\jre1.8.0_74。

Note that one is jdk 1.8.0_74 and the other is jre 1.8.0_74注意一个是jdk 1.8.0_74,另一个是jre 1.8.0_74

I was rushing things, and thinking the installer was asking me the same question twice, set both my JDK and JRE install locations to D:\\devtools\\jdk\\jdk1.8.0_74, resulting in the installer overwriting the JDK with the JRE.我很着急,认为安装程序两次问我同样的问题,将我的 JDK 和 JRE 安装位置都设置为 D:\\devtools\\jdk\\jdk1.8.0_74,导致安装程序用 JRE 覆盖了 JDK。 This resulted in (among other things) a missing javac.exe in my JDK bin, and the same error the OP reported here in all my maven builds.这导致(除其他外)我的 JDK bin 中缺少 javac.exe,并且 OP 在我的所有 maven 构建中报告了相同的错误。

I got a solution.我得到了解决方案。

The most common solution for this problem is to change jdk location as my Installed JREs instead of the JRE location but that did not solve my problem this one time.此问题最常见的解决方案是将jdk 位置更改为我安装的 JRE而不是JRE 位置,但这一次并没有解决我的问题。

So I did the below to solve the problem.所以我做了下面的事情来解决这个问题。 Expand the Installed JREs tab and you will find a Execution environments tab.展开已安装的 JRE选项卡,您将找到一个执行环境选项卡。

Click on your favourite execution environment.单击您最喜欢的执行环境。 In my case it was JAVASE-1.8 .就我而言,它是JAVASE-1.8 There it shows 2 options.在那里它显示了 2 个选项。 JDK and JRE . JDK 和 JRE Select JDK there and the problem is solved.在那里选择JDK ,问题就解决了。

在此处输入图片说明

I tried most of the answers without success.我尝试了大部分答案都没有成功。 What worked for me was (after following https://stackoverflow.com/a/21279068/2408893 ):对我有用的是(在关注https://stackoverflow.com/a/21279068/2408893 之后):

  • right click on project -> Properties右键单击项目-> 属性
  • select Java Build Path选择 Java 构建路径
  • select the JRE System Library选择 JRE 系统库
  • click edit点击编辑
  • In execution environment select a jdk在执行环境中选择一个jdk

在此处输入图片说明

  • click Finish单击完成
  • build and run构建并运行

I just wasted 3 hours with this problem until I managed to make it work.我只是在这个问题上浪费了 3 个小时,直到我设法让它发挥作用。 I had this error in the Eclipse Terminal when issuing a mvn compile command:发出 mvn compile 命令时,我在 Eclipse 终端中遇到此错误:

No compiler is provided in this environment.此环境中不提供编译器。 Perhaps you are running on a JRE rather than a JDK?也许您在 JRE 而不是 JDK 上运行?

So I read here that I have to make a new system variable called JAVA_HOME and make it point towards the jdk installation folder.所以我在这里读到我必须创建一个名为 JAVA_HOME 的新系统变量,并使其指向 jdk 安装文件夹。 However this generated another error:然而,这产生了另一个错误:

Source option 1.5 is no longer supported.不再支持源选项 1.5。 Use 1.6 or later使用 1.6 或更高版本

Couldn't find a fix for this one so...找不到解决这个问题的方法,所以......

So the fix to make it all go away is install Java SE Development Kit 8!因此,让这一切消失的修复方法是安装 Java SE Development Kit 8! I was using 9 thinking that if it's the latest it must be better...我在使用 9 时认为如果它是最新的,它一定会更好......

Anyway...反正...

  1. Uninstall all java versions from your computer从您的计算机上卸载所有 Java 版本
  2. Install JDK8 from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html从这里安装 JDK8: http : //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  3. Then define the JAVA_HOME system environmental value - tutorial here: https://docs.oracle.com/cd/E19509-01/820-3208/inst_cli_jdk_javahome_t/然后定义JAVA_HOME系统环境值——教程在这里: https : //docs.oracle.com/cd/E19509-01/820-3208/inst_cli_jdk_javahome_t/

  4. Restart Eclipse and enjoy!重新启动 Eclipse 并享受! (at least that's what I did) (至少我是这样做的)

Hoping this spares some poor wanderer of some trouble.希望这能让一些可怜的流浪者免于麻烦。

In my case I had system variable path has "C:\\ProgramData\\Oracle\\Java\\javapath" location.就我而言,我的系统变量路径具有“C:\\ProgramData\\Oracle\\Java\\javapath”位置。

In "C:\\ProgramData\\Oracle\\Java\\javapath" location java, javaw only there.在“C:\\ProgramData\\Oracle\\Java\\javapath”位置java,javaw只在那里。 So I am getting the same error.所以我得到了同样的错误。

Once I removed all files in "C:\\ProgramData\\Oracle\\Java\\javapath" folder my error got resolved.一旦我删除了“C:\\ProgramData\\Oracle\\Java\\javapath”文件夹中的所有文件,我的错误就得到了解决。

Try this.尝试这个。

<build>
...
    <plugins>
    ...
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
                <executable> path to jdk \bin\javac.exe</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

我遇到了同样的问题,我犯的错误是我只在路径 var 中添加了 jre 路径,而不是 jdk 路径。当 jdk 路径添加到路径并构建 Maven 项目时,它的工作完美。谢谢大家

I did the following change and it worked for me.Hope it helps someone.我做了以下更改,它对我有用。希望它可以帮助某人。 在此处输入图片说明

I was getting the same error when I created a new EC2 ubuntu 16.04 instance with Java already installed on it and while running mvn clean package, I encountered this issue and the below solution worked for me.当我创建一个新的 EC2 ubuntu 16.04 实例并且已经安装了 Java 并且运行 mvn clean package 时,我遇到了同样的错误,我遇到了这个问题,下面的解决方案对我有用。

If you are working on an Ubuntu server, then you can try installing Java again and for that you can use this answer How to install the JDK on Ubuntu Linux如果您在 Ubuntu 服务器上工作,那么您可以尝试再次安装 Java,为此您可以使用此答案如何在 Ubuntu Linux 上安装 JDK

In Windows 7 - 64 bit, there is a permissions problem which prevents the installer from unpacking the file C:\\Program Files\\Java\\jdk1.6.xx\\lib\\tools.jar into your local.在 Windows 7 - 64 位中,存在一个权限问题,它阻止安装程序将文件 C:\\Program Files\\Java\\jdk1.6.xx\\lib\\tools.jar 解压到本地。 This jar file is what maven-compiler-plugin version 3.x uses instead of the usual javac这个 jar 文件是 maven-compiler-plugin 版本 3.x 使用的,而不是通常的 javac

Solution: Run, as an administrator, the Java JDK installer!解决方案:以管理员身份运行 Java JDK 安装程序! And make sure the tools.jar is sitting in the C:\\Program Files\\Java\\jdk1.6.xx\\lib\\并确保 tools.jar 位于 C:\\Program Files\\Java\\jdk1.6.xx\\lib\\

In case you are using m2e maven integration plugin, you want to see the file is visible to Eclipse via the following steps inside Eclipse:如果您使用的是 m2e maven 集成插件,您希望通过 Eclipse 中的以下步骤查看该文件对 Eclipse 可见:

Go to Window -> Preferences -> Java -> installed JREs Select the JDK you are using (C:\\Program Files\\Java\\jdk1.6.xx) Press Edit to see the list of jars including tools.jar, OR you can add it as Add External JAR Then configure the maven run through these steps:转到 Window -> Preferences -> Java -> installed JREs 选择您正在使用的 JDK (C:\\Program Files\\Java\\jdk1.6.xx) 按 Edit 查看包含 tools.jar 的 jar 列表,或者您可以将其添加为 Add External JAR 然后通过以下步骤配置 maven 运行:

Run->Run configurations->Fill in Name, Base directory and Goals.运行->运行配置->填写名称、基本目录和目标。 Then in the same window move to the JRE tab and point to the JDK \\jdk1.6.xx\\然后在同一个窗口中移动到 JRE 选项卡并指向 JDK \\jdk1.6.xx\\

In addition to answer above, I could say that just try to run Maven from the terminal (outside of Eclipse).除了上面的回答,我可以说只是尝试从终端(Eclipse 之外)运行 Maven。 In this way, if it builds from outside but not in Eclipse, you can understand that the problem should be in Eclipse.这样,如果是从外部构建而不是在Eclipse中构建,则可以理解问题应该在Eclipse中。

There are several answers regarding this question but all are related to right path configuration of JDK, but with JRE only we can solve this problem.关于这个问题有几个答案,但都与JDK的正确路径配置有关,但只有JR​​E才能解决这个问题。

We just need to make use of deployment assembly to configure the path of packaged war file of the Java EE Project and then re-run the maven-install.我们只需要利用部署组件配置Java EE项目打包war文件的路径,然后重新运行maven-install即可。

Steps to make use of deployment assembly:使用部署程序集的步骤:

  1. Right click on the Jave EE project --> click on Properties --> click on Deployment Assembly右键单击 Java EE 项目 --> 单击属性 --> 单击部署程序集

  2. Click on Add button --> Click on Archives from the File System --> Click on next --> Click on Add --> Go to the .m2\\respository directory and search for the war file generated --> Select war file --> Click on Open button --> Click on Apply --> OK点击添加按钮-->点击文件系统中的档案-->点击下一步-->点击添加-->进入.m2\\respository目录并搜索生成的war文件-->选择war文件--> 点击打开按钮 --> 点击应用 --> 确定

  3. Right click on the project --> Click on Maven Install under Run As右击项目-->点击Run As下的Maven Install

This will build your project successfully, without any compiler error.这将成功构建您的项目,而不会出现任何编译器错误。

Hope this solves the problem without JDK.希望这可以解决没有 JDK 的问题。

Are you missing any maven build. 你错过了任何maven构建吗?

Apart from above JRE changes.I still faced similar issue.I was missing JUnit dependency after adding it is working fine. 除了上面的JRE更改。我仍然遇到类似的问题。我添加它后工作正常,我缺少JUnit依赖。

Hope this will help. 希望这会有所帮助。

I went to Preferences --> Java --> Installed JREs I did NOT see the JDK in here. 我去了Preferences - > Java - > Installed JREs我没有在这里看到JDK。 I only saw the JRE here. 我这里只看到了JRE。 So I added the JDK. 所以我添加了JDK。

here we have to mandatory remove JRE instead of just unchecking. 在这里我们必须强制删除JRE而不是仅仅取消选中。

right click on your project and run as maven install then again run your application.右键单击您的项目并作为 maven install 运行,然后再次运行您的应用程序。 if this didnt work go to the folder of your project directly start command line and run 'mvn install'如果这不起作用,请转到您项目的文件夹直接启动命令行并运行“mvn install” 在此处输入图像描述

In Linux, doing a docker example, I must not have had the JDK installed just the JRE.在 Linux 中,做一个 docker 示例,我一定不能只安装 JRE 的 JDK。 After sudo apt install openjdk-8-jdk and setting JAVA_HOME in profile and adding JAVA_HOME/bin to the path, it built!sudo apt install openjdk-8-jdk并在配置文件中设置 JAVA_HOME 并将 JAVA_HOME/bin 添加到路径之后,它就构建了!

对我来说,我已经升级到 Big Sur Mac OS,我必须删除它,然后它运行良好。

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

This is because it is looking for JDK and is founding JRE.这是因为它正在寻找 JDK 并正在创建 JRE。

Recommended Solution:推荐解决方案:

Window > Preferences > Java > Installed JREs > Edit > Click on directory > Browse JDK path....窗口 > 首选项 > Java > 已安装的 JRE > 编辑 > 单击目录 > 浏览 JDK 路径...。

That should work fine.那应该可以正常工作。
It worked fine for me!!它对我来说很好!

While building the project, make sure to point the jre to jdk path.在构建项目时,确保将 jre 指向 jdk 路径。 This can be done in Run configuration section for the particular project.这可以在特定项目的运行配置部分中完成。

Please for windows uses请为windows使用

  1. If you are using intellij, just after adding JAVA_HOME open command prompt from project directory and run mvn clean install(don't use intellij terminal).如果您使用的是 intellij,只需在添加 JAVA_HOME 后从项目目录打开命令提示符并运行 mvn clean install(不要使用 intellij 终端)。

  2. set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202设置 JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此环境中不提供编译器。 也许您在 JRE 而不是 JDK 上运行? - 但是选择了jdk - No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? - but jdk selected Mac os 大苏尔 | 此环境中不提供编译器。 也许您在 JRE 而不是 JDK 上运行? - Mac os Big Sur | No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? Jenkins Windows slave:此环境不提供编译器。 也许您在 JRE 上运行而不是在 JDK 上运行 - Jenkins Windows slave: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK mvn clean package error: 此环境没有提供编译器。 也许您在 JRE 而不是 JDK 上运行? - mvn clean package error: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? jenkins 管道错误 此环境中未提供编译器 也许您在 JRE 上而不是 JDK 上运行 - jenkins pipeline error No compiler is provided in this environment Perhaps you are running on a JRE rather than a JDK 也许您在 JRE 而不是 JDK 上运行? - Perhaps you are running on a JRE rather than a JDK? Maven 错误:也许您在 JRE 而不是 JDK 上运行? - Maven error :Perhaps you are running on a JRE rather than a JDK? Eclipse中的Maven项目 - 也许您运行的是JRE而不是JDK - Maven project in Eclipse - Perhaps you are running on JRE rather than JDK 此环境中未提供编译器。 - Eclipse - Maven - java-8-openjdk - Xubuntu - No compiler is provided in this environment. - Eclipse - Maven - java-8-openjdk - Xubuntu 此环境中不提供编译器。 执行 mvn clean package 时 - No compiler is provided in this environment. When execute mvn clean package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM