• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Maven Compile Failure: Maven Thinks JDK Is JRE

 
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to build a fat JAR using Maven and have written my application in Java 8.  The version of Java I am using is the JDK 1.8.0_77 (I've confirmed that this is on my project build path in Eclipse).  When I run a Maven clean install I receive the following error:






I thought initially this might be an issue with Eclipse but I tried running a clean install from the Command Prompt.  Same issue.  This is the error trace:



C:\Users\<My Directory>\Documents\Development\Java\Workspace\MyApp>mvn -e clean install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyApp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MyApp ---
[INFO] Deleting C:\Users\<My Directory>\Documents\Development\Java\Workspace\MyApp\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MyApp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 13 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MyApp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 31 source files to C:\Users\<My Directory>\Documents\Development\Java\Workspace\MyApp\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: 1.154 s
[INFO] Finished at: 2016-10-12T12:00:59+01:00
[INFO] Final Memory: 9M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MyApp: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MyApp: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

       at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
       at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
       ... 20 more
[ERROR]
[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

C:\Users\<My Directory>\Documents\Development\Java\Workspace\MyApp>





Does anyone know why my version of Maven seems to think the JDK is a JRE and can't see the compiler?
 
Sheriff
Posts: 21787
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the value of environment property JAVA_HOME? Because step 1 of http://maven.apache.org/install.html says to make sure that JAVA_HOME is correctly set to your JDK folder.
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, my JAVA_HOME is set to my JDK

echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_77

Here are the contents of my POM.xml

 
Saloon Keeper
Posts: 10523
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you run 'mvn -v' and report the output?
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: C:\Java\apache-maven-3.3.9
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_77
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have other versions of Java in my C:\Program Files\Java folder:

C:\Program Files\Java\jdk1.7.0_51
C:\Program Files\Java\jdk1.7.0_80
C:\Program Files\Java\jdk1.8.0_77
C:\Program Files\Java\jre1.8.0_66

Could this cause an issue?
 
Sheriff
Posts: 6182
163
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you execute "javac -version" at the command line?  If it is the wrong version, check your PATH variable.  If the command is not found, append ;%JAVA_HOME%\bin to your PATH.
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean "java -version"?  This is the output:

java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

I've checked my PATH variable and C:\Program Files\Java\jdk1.8.0_77\bin is on the path.

(Apologies, I only saw now how my XML code has distorted the length of the page - can't seem to be able to edit my post!)
 
Knute Snortum
Sheriff
Posts: 6182
163
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Simon Ritchie wrote:You mean "java -version"?  


No, I actually mean javac.

I've checked my PATH variable and C:\Program Files\Java\jdk1.8.0_77\bin is on the path.


Then javac should work, although it could be the wrong version

(Apologies, I only saw now how my XML code has distorted the length of the page - can't seem to be able to edit my post!)


I edited it for you.  You can press the "Preview" button before the "Submit" button when you're replying to see how the post is rendered.
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the edit.

This is the result for "javac -version"

javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.
 
Rob Spoor
Sheriff
Posts: 21787
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you list the contents of C:\Program Files\Java\jdk1.8.0_77 and of C:\Program Files\Java\jdk1.8.0_77\bin? More precisely, can you check if C:\Program Files\Java\jdk1.8.0_77 contains sub folders called jre and include, and if C:\Program Files\Java\jdk1.8.0_77\bin contains files javac.exe and javadoc.exe?
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C:\Program Files\Java\jdk1.8.0_77\bin does not contain any file named javac.exe or javadoc.exe.  That's strange.  

The C:\Program Files\Java\jdk1.8.0_77 folder does contain subfolders jre and include.  There are quite a lot of files in C:\Program Files\Java\jdk1.8.0_77.  Not sure if you really want to see all of them!
 
Stephan van Hulst
Saloon Keeper
Posts: 10523
224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then that's the problem. Your JDK should contain those files. It appears your installation is corrupt.
 
Simon Ritchie
Ranch Hand
Posts: 179
13
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.  My employer doesn't allow me to edit the contents of those folders so I'll have to arrange for a new install.  I'll see how it goes.
 
Rob Spoor
Sheriff
Posts: 21787
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Simon Ritchie wrote:C:\Program Files\Java\jdk1.8.0_77\bin does not contain any file named javac.exe or javadoc.exe.  That's strange.  

The C:\Program Files\Java\jdk1.8.0_77 folder does contain subfolders jre and include.  There are quite a lot of files in C:\Program Files\Java\jdk1.8.0_77.  Not sure if you really want to see all of them!


I agree with Stephan's conclusion. The JDK folder shouldn't contain that many files. My own installation contains the following:
  • bin folder
  • db folder
  • include folder
  • jre folder
  • lib folder
  • COPYRIGHT file
  • javafx-src.zip file
  • LICENSE file
  • README.html file
  • release file
  • src.zip file
  • THIRDPARTYLICENSEREADME.txt file
  • THIRDPARTYLICENSEREADME-JAVAFX file

  • If your installation contains many more files, then these probably belong in one of the sub folders. Most (but not all) of the .exe files belong in bin, for instance. It wouldn't surprise me if they are located in your installation's root folder instead.
     
    Simon Ritchie
    Ranch Hand
    Posts: 179
    13
    Hibernate Eclipse IDE Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The good news is that I've had a new installation of JDK1.8.0_77 installed and the "javac -version" command is now working in the prompt, i.e.: it returns the path to this installation of the JDK.  So it looks like I have a working version of JDK8 running.

    In Eclipse I ran a clean install on my project but am now getting this output



    I can't find any useful information on that missing class org/codehaus/plexus/compiler/util/scan/InclusionScanException

    Does anyone know what might be the issue here?
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 10523
    224
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well frankly, your dependency graph is quite a mess.

    You can probably remove the dependencies on maven-compiler-plugin (which is a plugin, not a dependency) and plexus-utils, and this will solve your problem.

    You can remove hibernate-core and spring-tx, which are already transitive dependencies from hibernate-entitymanager and spring-orm respectively.

    You will probably also want to remove log4j-over-slf4j and log4j, unless you have non-maven dependencies that require Log4j, in which case you should only delete log4j.

    Finally, you can exclude commons-logging from spring and spring-orm, and add a dependency on jcl-over-slf4j. This will cause Spring to log through your SLF4J implementation (in this case, Logback).

    This is the POM I ended up with:
     
    Simon Ritchie
    Ranch Hand
    Posts: 179
    13
    Hibernate Eclipse IDE Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks.  Yes, my dependencies are messy and I'm still a newcomer to Maven so as you can see my understanding of the technology isn't complete yet.  I've made those changes you suggested to the POM.

    Now, I get the following error which is focussed on a compilation error due to a lambda expression in one of my classes



    I don't understand why Eclipse sees the source as 1.5.  I've changed my build path to use 1.8 and there is no reference to 1.5 in the POM.  Whenever I go to Maven -> Update Project however my JRE System Library reverts to 1.5
     
    Knute Snortum
    Sheriff
    Posts: 6182
    163
    Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Maven's default for the Java version is strangely still 1.5.  To change that, you need something like this in your POM:

     
    Simon Ritchie
    Ranch Hand
    Posts: 179
    13
    Hibernate Eclipse IDE Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That worked perfectly, thanks Knute and to all others who answered.
     
    Stephan van Hulst
    Saloon Keeper
    Posts: 10523
    224
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Alternatively, you can also configure it with a user property:
     
    Simon Ritchie
    Ranch Hand
    Posts: 179
    13
    Hibernate Eclipse IDE Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also works, thanks Stephan
     
    You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!