pt123
pt123

Reputation: 2166

NDK javah fails : class file has wrong version 50.0, should be 49.0

I have looked at the various posts regarding javah failing but I have not found anything with this error that I am getting:

error: cannot access com.acme.ndktest.Sample
bad class file: bin/classes/com/acme/ndktest/Sample.class
class file has wrong version 50.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
com.sun.tools.javac.util.Abort
    at com.sun.tools.javac.comp.Check.completionError(Check.java:169)
    at com.sun.tools.javadoc.DocEnv.loadClass(DocEnv.java:149)

The closest information I could find on the Internet was this http://yonghoon.wikidot.com/ndk#toc4

Each new release of the JVM increments the version number of the class file. The list below shows the class version numbers that I know Java 6: Version 50.0 Java 5 (1.5): Version 49.0 Java 1.4.2: Version 48.0

I don't get it I am using 1.6, Eclipse is set to JDK compliance 1.6, I am running javah from the /usr/lib/jvm/java-6-sun/jdk1.6.0_31/bin/javah folder.

/usr/lib/jvm/java-6-sun/jdk1.6.0_31/bin/javah -classpath bin/classes -jni com.acme.ndktest.Sample

I am not sure why it says it should be 49, when I am using 1.6.

Some more information javac -version -> javac 1.6.0_31 javap -v -classpath bin/classes com.acme.ndktest.Sample | grep version minor version: 0, major version: 50

In /etc/alternatives most of the java items point to java-6-sun like java and javac But javaws points java-6-openjdk-amd64

I am Running Eclipse 3.7 Also does Ant have anything to with building these headers

Upvotes: 0

Views: 2014

Answers (1)

pt123
pt123

Reputation: 2166

The issues was that some packages had been installed into the /usr/java/packages/lib/ext by another application.

These were being used by javac to see decide the maximum possible jdk version to use. So doing this would fail

javac SomeFile.java -target 1.6 

Giving this error message Javac version 1.6 not able to build for target 1.6

When you ran it with verbose option javac -verbose -version SomeFile.java

it would list all the files in the /usr/java/packages/lib/ext

After moving all the files out of /usr/java/packages/lib/ext

It compiles fine.

Upvotes: 0

Related Questions