0

I'am trying to execute a java program with mvn, but there's a little problem I can't solve. Maven says:

java.lang.UnsupportedClassVersionError: main/CsvCrawler : Unsupported major.minor version 51.0

So my java version is not compatible to the stuff used in the program. But I can't figure how to update my java, actually I don't even understand what to update... :-)

Some other info:

java version "1.6.0_27"
javac 1.7.0_25

Can someone give me a hint what to do? Thanks for any suggestions!

3
  • 1
    I think it should have appeared in the suggested question list.. please do try reading it next time.
    – icedwater
    Oct 6, 2013 at 16:58
  • @icedwater I did it, but didn't understand the other postings
    – Crayl
    Oct 6, 2013 at 17:29
  • 1
    I see, I'm glad you got your answer here though.
    – icedwater
    Oct 7, 2013 at 1:27

2 Answers 2

4
Unsupported major.minor version 51.0

This indicates that you are compiling your class using a 1.7 compiler and targeting the 1.7 VM. When you run it on a 1.6 VM, that's its way of saying "Hey, I have no idea what this format is" because it came out after the 1.6 VM did.

To fix, either upgrade your VM (you are currently running 1.6.0_27) to 1.7, or tell your compiler (you are running 1.7.0_25) to target 1.6.

1
  • Thank you very much for this understandable explanation :-)
    – Crayl
    Oct 6, 2013 at 17:23
1

One option would be to make Maven use specific compiler. Put the following into your pom.xml file:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

This will make your code runnable on 1.6 JVM. You can play around with source/target tag values to match your needs.

Not the answer you're looking for? Browse other questions tagged or ask your own question.