java.lang.UnsupportedClassVersionError: Bad version number in .class file error while executing run_cmdline.sh
Asked by Shivansh Singh:

I am using UWC to covert my Mediawiki pages into text file which I will later import it to Confluence. My Mediwiki is installed on a linux box and I am using command line to export the pages. UWC is installed on the same machine on which Mediawiki is present. The Java version is JDK 1.5.0_10. When I run the command I am getting following error:

uwc$ /bin/bash run_cmdline.sh -e conf/exporter.mediawiki.properties

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:620)

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 java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Can anyone help me out with this issue?


Answers:
author: m@
body: This error will be thrown when you try and load a class thats been compiled with an incompatible (usually future) version of Java.

From your question it looks like the class you're trying to run was compiled using Java 6 and you're using Java 5 to run it. Try upgrading your JVM to 6 and give it another go.

comments: author: Shivansh Singh
body: Hi Matthew,

Thanks for your reply.

I have downloaded the uwc.zip from <https://studio.plugins.atlassian.com/wiki/display/UWC/Universal+Wiki+Converter> and its mentioned in the documentation that any version of Java 5 or higher should be fine for the installation and running UWC. So I was wondering why it didn't work when I have JDK 1.5.0_10 installed on my m/c.


author: m@
body: I downloaded the converter, extracted the starting point class and confirmed its been compiled without java 5 support:

```
$ file ./com/atlassian/uwc/ui/UWCCommandLineInterface.class
./com/atlassian/uwc/ui/UWCCommandLineInterface.class: compiled Java class data, version 50.0 (Java 1.6)
```

I'm going to do some investigating as to why this is the case or if its just an oversight.


author: Laura Kolker
body: Yeah, that's my bad. I've updated the doc to say it requires Java 6 now. It's not so much that we couldn't support Java 5. It's just that at this point, I'm using Java 6, and when I build the UWC and one of the dependencies (confluence remote java wrapper), I happen to be using 6. So, if you need it to support 5, and you're willing to build from source, it _should_ be possible, but you have to not only build the UWC against 5, but also the CRJW library and update the lib directory with the resulting jar.


author: Shivansh Singh
body: Thanks Laura !! I am sure it will avoid confusion to others who will be using UWC.

One quick question. Do you know if we can use UWC to export only subset of Mediawiki?


Tags: universal-wiki-converter