Compiling Java 7 code via Maven

前端 未结 18 1236
夕颜
夕颜 2020-12-04 07:10

My pom file lists


  
    
        
            
                

        
相关标签:
18条回答
  • 2020-12-04 07:57

    None of the previous answers completely solved my use case.

    Needed to remove the directory that was being built. Clean. And then re-install. Looks like a silent permissions issue.

    0 讨论(0)
  • 2020-12-04 07:57

    I had this problem when working with eclipse, I had to change the project's build path so that it refers to jre 7

    0 讨论(0)
  • 2020-12-04 07:59

    Not sure what the OS is in use here, but you can eliminate a lot of java version futzing un debian/ubuntu with update-java-alternatives to set the default jvm system wide.

    #> update-java-alternatives -l
    java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
    java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
    java-6-sun 63 /usr/lib/jvm/java-6-sun
    java-7-oracle 1073 /usr/lib/jvm/java-7-oracle
    

    To set a new one, use:

    #> update-java-alternatives -s java-7-oracle
    

    No need to set JAVA_HOME for most apps.

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

    For a specific compilation that requires a (non-default /etc/alternatives/java) JVM, consider prefixing the mvn command with JAVA_HOME like this,

    JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/ mvn package
    

    Here we assume the default is Java 8, whereas for the specific project at hand we require Java 7.

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

    I had the same problem and to solve this I follow this blog article: http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

    $ vim .bash_profile 
    
    export JAVA_HOME=$(/usr/libexec/java_home)
    
    $ source .bash_profile
    
    $ echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
    

    special tks to @mkyong

    EDIT: Now I'm using: jEnv + sdkman

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

    You might be specifying a wrong version of java. java -version(in your terminal) to check the version of java you are using. Go to maven-compile-plugin for the latest maven compiler version Your plugin may appear like this if you are using java 6 and the latest version of maven compiler plugin is 3.1

    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
    
    0 讨论(0)
提交回复
热议问题