0

I have a scenario where I need to run maven from a batch file to use JDK 8,I can't change the pom.xml nor can I change the environment variable.But I can change settings.xml.I get the following error as below:

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

I have setup profile as follows:

 <profile>
     <id>java8</id>
     <activation>
       <jdk>1.8</jdk>
     </activation>
   <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>   
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>    
        </plugin>
    </plugins>
  </build>
   </profile>

I have activated the profile using below line

<activeProfiles>
    <activeProfile>java8</activeProfile>
</activeProfiles>

But still I get the error No compiler is provided? How do I set the path variable to my Java Home.

Mr Ajay
  • 399
  • 1
  • 4
  • 18
  • That has nothing to do with the POM, but with the Java on the PATH. Maven picks up the Java from your PATH and sees that it is a JRE, but it needs a JDK. – J Fabian Meier May 08 '20 at 08:13
  • java version "1.8.0_202-ea" Java(TM) SE Runtime Environment (build 1.8.0_202-ea-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b03, mixed mode) – Mr Ajay May 08 '20 at 08:17
  • How to make it pick up my JDK without modifying the path in environment variables nor pom.xml – Mr Ajay May 08 '20 at 08:19
  • https://stackoverflow.com/a/36647171/927493 – J Fabian Meier May 08 '20 at 08:22
  • JAVA_HOME is the one which is needed to be changed... – khmarbaise May 08 '20 at 08:51
  • Use a toolchain otherwise: https://maven.apache.org/guides/mini/guide-using-toolchains.html You are the free from running Maven with any JDK and compiling your code with JDK8 (or other) – NoDataFound May 08 '20 at 10:33

0 Answers0