Maven Package Compilation Error

后端 未结 12 1689
栀梦
栀梦 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 07:51

    Go to windows -> Preferences -> Java -> Installed JREs

    may be jre is already added

    click on Add -> Standard VM -> Next -> Directory

    and browse for the JDK in my case path was C:\Program Files\Java\jdk1.8.0_111

    then Click on finish.

    you will see window like this

    select JDK -> Apply -> Ok

    And You are done.

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

    What worked for me (32-Bit Windows 7) was to add the following to your path environment variable:

    %JAVA_HOME%\lib;

    0 讨论(0)
  • 2020-12-05 08:02
    1. Check your installation JDK and its path - download link

    2. Check its path on environmental variables - check

    3. Add eclipse windows->preferences->Java->installed JREs->add->standart VM -> JRE home (jdk path exmp:'C:\Program Files\Java\jdk1.8.0_221') then apply.

    4. right click your project -> properties -> select (Libraries -> JRE System libraries) -> edit -> choose workspace default JRE (JDK.1.8.0_221)

    5. Right-click your project -> Maven update clean and install project again.

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

    There are several options to specify.

    Steps: Right on project in project explorer Go to Run-> Run Configuration -> Click Maven Build -> Click on your build config/or create a new config. You will see the window as the given snapshot below, click on JRE tab there.

    You see you have 3 options 1) Workspace Default JRE 2)Execution Environment 3)Alternate JRE 1) Workspace Default JRE is set from 'Window' menu on the top -> Preferences -> Java -> Installed JREs -Here you can add your jdk 2) Execution Environment jdk can be set in pom.xml

    <build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <fork>true</fork>
            <executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
        </configuration>
    </plugin>
    

    3) Alternate JRE can be used to select a jdk from your directory

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

    Go to preferences>installed JRE>

    then click add

    select C:\program files\java\

    press enter

    it will search for other jre's than jdk and then choose what is not selected

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

    In my case, the error "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK" was due to the JRE being installed in a different location than its default under the JDK.

    Running under 64-bit linux, I have Oracle's 64-bit JDK SE 1.6.0_45 installed at /opt/java. The 32 and 64 bit JRE's were installed at /opt/java/jre32 and /opt/java/jre64, with a jre symlink: (ie. ln -s jre64 jre), sojre ->./jre64(meaning/opt/jdk/jrewas a symlink referencing/opt/jdk/jre64).

    Once I renamed jre64 to jre (ie. rm jre ; mv jre64 jre ; ln -s jre jre64), this problem went away; and I was able to build using maven (inside of netbeans).

    Maven appears to be looking at the JRE path, saying "jre64 isn't the correct name for a default JRE-inside-of-JDK install, so assume a JDK doesn't exist at ../"), which would prevent it from resolving the location of the JDK lib directory containing tools.jar, etc.

    Haven't tested it, but the same thing might happen under Windows if the JRE isn't in the default location (or perhaps isn't in the %JAVA_HOME%\jre directory). If both the JDK and the JRE are installed, Oracle's installer wants to install the JRE at %JAVA_HOME%\jre6, not %JAVA_HOME%\jre. That may be because the \jre directory is needed for the JDK uninstall process; if the JRE has been installed on top of the JDK's JRE in the \jre directory, instead of at \jre6, uninstalling the JDK after the uninstalling the JRE will fail unless the \jre directory is copied, JRE is uninstalled, and the \jre copy is restored to \jre.

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