Alok
Alok

Reputation: 184

Unsupported major.minor version 51.0 exception while using Hibernate tools

I am using hibernate tools with hibernate 3. JDK version is 1.6. However when I run this hibernate tool it by default takes jdk 1.4 as you can see in the code. and because of that I am getting this error.

16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA  
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found  
32 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist  
32 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling  
63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: 
C:\Documents and Settings\lakhan\workspace\dpppbuild\dpp_core\build.xml:332:    java.lang.UnsupportedClassVersionError: com/pyyyy/pccc/dtt/core/hibernate/DppppProductMatchesPK : Unsupported major.minor version 51.0

Please help me to sort out this issue. I am notable to figure how can i change the target jdk from 1.4 to 1.6. I am using build.xml to execute this hibernate tool.

Upvotes: 1

Views: 2106

Answers (2)

Ivan Mushketyk
Ivan Mushketyk

Reputation: 8295

It seems that the application that you are running was built using a newer version of JDK. You need either to use older version of JDK to build your app or you can use newer version of JDK to run your app.

Alternatively you can specify which version of JDK to use during build.

In javac you should you flags source and target:

javac -source 1.4 -target 1.4

If you are building using Ant you should do:

<javac srcdir="${src}"
         destdir="${build}"
         fork="true"
         source="1.4"
         target="1.4"
  />

If you are building using Maven you should do:

<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.4</source>
          <target>1.4</target>
        </configuration>
      </plugin>
    </plugins>

Upvotes: 0

Kayaman
Kayaman

Reputation: 73558

It's not defaulting to jdk 1.4, it's saying that it's using "JDK 1.4 Timestamp handling".

The major.minor version 51.0 is JDK 7, so you're using a too low version of JDK.

Upvotes: 1

Related Questions