Maven Package Compilation Error

后端 未结 12 1690
栀梦
栀梦 2020-12-05 07:39

i created a webapp project using maven in eclipse. when i run the command mvn package in command prompt it showing folowing error.

[ERROR] COMPILATION ERROR         


        
相关标签:
12条回答
  • 2020-12-05 08:06

    to set path in below manner

    keep jdk's path at first place in path variable, so that other java path will be ignored. compilation error will be resolved.

    0 讨论(0)
  • 2020-12-05 08:07

    After creating a second workspace to work in a separate source code branch, I ran into a bizarre situation where I could do a Maven build from the command line in the new workspace, but not in Eclipse. I tried setting the JRE configuration to the JDK as described by others, but still no luck. I finally had to search the entire contents of the new workspace's .metadata directory to find the offending files that refused to be reconfigured. The main culprit was

    .plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs
    

    It still pointed to the wrong directory despite my configuration change. I did a manual edit to supply the correct JDK name and location. I also edited the files under

    .plugins/org.eclipse.debug.core/.launches
    

    These all likewise pointed to the JRE instead of the JDK. Once these edits were made, I could build projects in the second workspace from within Eclipse, not just from the command line.

    0 讨论(0)
  • 2020-12-05 08:08

    I'm using maven plugin for Eclipse (V3.3) and was struggling with this error for a while. I finally found the solution which is linked to stale java sources: it has nothing to do with JRE or JDK (I use JRE 1.7).

    I found on other forums that it is a known problem in maven-compiler-plugin (same result for V3.3 and 3.5.1).

    So, I just recompiled manually the stale source(s) and ran again the goal, this time without any problem.

    To figure out stale sources, run the goal with option -X (debug) and look for entries beginning with

    [DEBUG] Stale source detected:
    

    indicating a java class file (to be recompiled manually...).

    Hope this can be useful as the message given by maven compiler made me search in a wrong direction (play with JRE, JDK, JAVA-HOME, etc).

    0 讨论(0)
  • 2020-12-05 08:13

    Go to your 'Runtime Configuration' and configure your JRE to an JDK.

    Or as @PawanKumarBaranwal suggested, set your default JDK. But care if you have more than one JRE configured.

    0 讨论(0)
  • 2020-12-05 08:14

    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. This jar file is what maven-compiler-plugin version 3.x uses instead of the usual javac

    Solution: Run, as an administrator, the Java JDK installer! And make sure the tools.jar is sitting in the 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:

    • 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, OW you can add it as Add External JAR

    Then configure the maven run through these steps:

    • 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\
    0 讨论(0)
  • 2020-12-05 08:16

    Try this. Go to Window --> Preferences --> Java --> Installed JREs.

    Double click the JRE, which is inside installed JREs.

    Give the JDK path (for example, C:\Program Files\Java\jdk1.7.0_80\) in JRE Home, and give JRE name as JDK. Click on Finish and then OK.

    For me it worked.

    0 讨论(0)
提交回复
热议问题