quimnuss
quimnuss

Reputation: 1561

javah not found error on jdk1.6 but not on jdk1.7

If I run

"C:\Program Files\Java\jdk1.6.0_24\bin\javah.exe" HelloWorld

I get

error: cannot access HelloWorld

but with

"C:\Program Files\Java\jdk1.7.0_15\bin\javah.exe" HelloWorld

the HelloWorld.h is generated

What's wrong? I have the 1.7 on the PATH, in case it were related...

class HelloWorld {
 private native void print();
}

Upvotes: 2

Views: 627

Answers (2)

Andrew Eidsness
Andrew Eidsness

Reputation: 1621

In my case the problem was that java7 would work with a .java file as input, but java6 seems to need the .class file. Changing the value of -classpath from src to bin fixed the problem for me.

I.e., when my files look like:

src/pkg/Hello.java
bin/pkg/Hello.class

I can do any of these:

$JAVA_6/javah -classpath -jni -d . -classpath bin pkg.Hello
$JAVA_7/javah -classpath -jni -d . -classpath bin pkg.Hello
$JAVA_7/javah -classpath -jni -d . -classpath src pkg.Hello

But not this:

$JAVA_6/javah -classpath -jni -d . -classpath src pkg.Hello

I'm using openjdk on linux.

Upvotes: 1

John Kane
John Kane

Reputation: 4453

I was not able to duplicate this when compiling under java6. Maybe uou compiled your class file with java7 and the Javah packaged with your java6 Jdk cannot read it.

Upvotes: 0

Related Questions