简体   繁体   中英

Jenkins Windows slave: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

I just setup a new jenkins slave which is running Windows server 2012. I already installed jdk-8u221-windows-x64 and set Java_home, Path like below

C:\Users\Administrator>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_221\

C:\Users\Administrator>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\
Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\
Program Files\Amazon\cfn-bootstrap\;C:\Program Files\Git\cmd;C:\Program Files\Ja
va\jdk1.8.0_221\\bin;C:\maven\bin;C:\maven\bin

However,build job running in this slave always complain that:

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

Any idea of what might be causing this?

Update Sep 11th, 2019

I configure the slave node as method 2 of Technext's suggestion 在此处输入图片说明

In a Job build configuration, I selected (System) in JDK option. If I choose JDK 8 update 221, this build job run successfully, but I want to use a (System) JDK which will get from environment variable in this node, so I can switch to another slave node without changing the JDK option. 在此处输入图片说明

However, when I remote to this server, and open command prompt, move on to workspace folder of this project, let say: C:\\jenkins_slave\\workspace\\project01\\, then type the command: mvn clean install, it run without complain about jdk or jre as run from Jenkins.

You may use any of these methods depending on what suits you:


Method 1 )

Please configure your Windows' Node to point it to the JDK you want to use by following these steps:

  1. Go to Manage Jenkins > Global Tool Configuration > JDK > Add JDK

    Since you already have Java installed, uncheck the box Install automatically

    In Name section, just provide some meaningful identifier, not necessarily JAVA_HOME . Now in the JAVA_HOME text box, you can provide any value that you wish because you are anyways going to use a different value for your Windows node.

在此处输入图片说明

  1. Now go to Manage Jenkins > Manage Nodes > (Go to Configure section of your Windows node) > Node Properties

    Now enable the check-box that says Tool Locations . Click Add > From the drop-down, select the name you provided to your JDK in Global Tool Configuration section

    Now here you have to provide the JAVA_HOME path for your Windows node. So wherever it is, just mention that path in the Home text box as shown below:

在此处输入图片说明


Method 2 )

Go to Manage Jenkins > Manage Nodes > (Go to Configure section of your Windows node) > Node Properties

Now enable the check-box that says Environment variables > Add

  • In Name text box, write Path (not PATH )
  • In Value text box, write the path of your JDK installation till bin as shown below.

在此处输入图片说明

In your case, add the following: C:\\Program Files\\Java\\jdk1.8.0_221\\bin;C:\\Windows\\System32;C:\\maven-3.6.1\\bin;%PATH%

I was not having Maven set in PATH so i added it to Node's configuration as shown above.

Note: In the Value text box, use semi-colon (;) as separator not comma (,)

Job's JDK config :

在此处输入图片说明

Job's command :

在此处输入图片说明

Job's output :

在此处输入图片说明


Method 3 )

In your Windows Node's configuration, enable Environment variables and add below variable with the relevant value

Name: java.home

Value: C:\\Program Files\\Java\\jdk1.8.0_221\\jre

Note : It's java.home (all in small letters as shown below)

在此处输入图片说明

JAVA_HOME needs to point to a JDK installation (maven needs the tools.jar ) but Maven actually uses the JRE within the JDK to run itself.

When using mvn -version , Maven uses Java's internal java.home property. This property is not the same thing as JAVA_HOME environment setting so it might fool you. It is actually a dynamic property showing you which JRE is running your code.

Ref: Java_home in Maven

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM