Why do I get "java.lang.UnsupportedClassVersionError: Bad version number in .class file" stacktrace at startup of "groovysh"?

Asked by Marius B. Kotsbak on 2012-05-03

$ groovysh
java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:152)
        at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:124)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at org.codehaus.groovy.tools.shell.Main.class$(Main.groovy)
        at org.codehaus.groovy.tools.shell.Main.$get$$class$org$fusesource$jansi$AnsiConsole(Main.groovy)
        at org.codehaus.groovy.tools.shell.Main.<clinit>(Main.groovy:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: groovy 2.0.0~beta2+isreally1.8.6-0ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
Uname: Linux 3.2.0-24-generic i686
NonfreeKernelModules: nvidia
ApportVersion: 2.0.1-0ubuntu7
Architecture: i386
Date: Thu May 3 12:11:55 2012
InstallationMedia: Kubuntu 10.10 "Maverick Meerkat" - Release i386 (20101007)
PackageArchitecture: all
ProcEnviron:
 LANGUAGE=nb_NO:nb:no_NO:no:nn_NO:nn:en
 TERM=xterm
 PATH=(custom, user)
 LANG=nb_NO.UTF-8
 SHELL=/bin/bash
SourcePackage: groovy
UpgradeStatus: Upgraded to precise on 2012-04-27 (6 days ago)

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu groovy Edit question
Assignee:
No assignee Edit question
Solved by:
Marius B. Kotsbak
Solved:
2012-05-03
Last query:
2012-05-03
Last reply:
2012-05-03
Marius B. Kotsbak (mariusko) said : #1

It seems to happen because I have JAVA_HOME set to a Java SDK 5.x and not 6.x.

Marius B. Kotsbak (mariusko) said : #2

Run "unset JAVA_HOME", update it to point to a Java 6.x (1.6), or remove it from ".bash_profile".