Farheen Khanum
Farheen Khanum

Reputation: 50

Build Failure error when Maven dependency for sql jdbc driver is added in pom.xml

I want to add the dependency for sql jdbc driver. Following is the snippet which I have added in pom.xml

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.5.0.jre9-preview</version>
            <scope>test</scope>
        </dependency>

Then i right clicked the project and clicked on maven Install,Here i got a build failed error.It has downloaded the jar files but i am getting the below error.

Console output:

    - maven-compiler-plugin:3.1:compile (default-compile) @ hybridFramework ---
    [INFO] Changes detected - recompiling the module!
    [

INFO] Compiling 27 source files to C:\Automation Testing softwares\seleniumHybridFramework-master\target\classes
[INFO] -------------------------------------------------------------
[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: 37.761 s
[INFO] Finished at: 2018-03-29T17:20:22+05:30
[INFO] Final Memory: 13M/45M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hybridFramework: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Can Anyone Help me on This?..

Upvotes: 0

Views: 1285

Answers (3)

Ullas Prabhakar
Ullas Prabhakar

Reputation: 3640

I you are using eclipse IDE Right click on project ->Build Path->Configure Build Path->Libraries

Configure JDK there instead of JRE

Upvotes: 1

Veselin Davidov
Veselin Davidov

Reputation: 7071

Maven is an external tool. Your IDE can call it with the right click and stuff but it is basically external tool. By default it uses your JAVA_HOME variable (which should point to JDK and not to JRE). You can check for example with:

C:\Users\User>echo %JAVA_HOME%
 Output:   C:\Program Files\Java\jdk1.8.0_152 

You can also use

mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=/path/to/the/javac compile

for compilation with a specific compiler but I guess that's not your problem. Just set your JAVA_HOME properly and you should be fine. Also you can try running command line maven. It will help debugging easier and is basically cleaner way to do it. Maybe the IDE is setting a java version different than the system one. You can check with

mvn -version

Also you can check if you have JDK or JRE by:

javac -version (this will work if you have JDK)

Upvotes: 0

Matteo Baldi
Matteo Baldi

Reputation: 5828

The problem is not caused by the dependency but, as clearly staded in the build log:

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

To set your JAVA_HOME and make Selenium WebDriver work look here

Upvotes: 1

Related Questions