Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've already .java file
I want to generate .h file using javah -jni command
eg.I have HelloWorld.java in E:\
In Command Prompt
E:\javah -jni HelloWorld.java
I found this error

error: cannot access HelloWorld.java
class file for HelloWorld.java not found
javadoc: error - Class HelloWorld.java not found.
Error: No classes were specified on the command line. Try -help.

Please help me:confused:
Posted

Of-course it will give error because you are using wrong command.
In short you are using HelloWorld.java which is FileName not Class Name.
E:\javah -jni HelloWorld.java   //HelloWorld.java is name of JavaFile not ClassFile


basically you need to know Actual Syntax which is
javah -jni ClassFile

you need to use
E:\javah -jni HelloWorld  //if HelloWorld is your ClassFile.


Hope it Will works for you. :)
 
Share this answer
 
v4
Comments
Richard MacCutchan 29-Dec-10 15:35pm    
What's the betting there is no reference to any native calls in HelloWorld?
RaviRanjanKr 31-Dec-10 6:42am    
Sorry Richard I am not getting What do you mean. be clear!
I've already tried.
I try
In Command prompt:
E:\javah -jni HelloWorld.class

I got the same error

error: cannot access test.class
class file for test.class not found
javadoc: error - Class test.class not found.
Error: No classes were specified on the command line. Try -help.

Help me :(
 
Share this answer
 
Comments
Richard MacCutchan 29-Dec-10 4:43am    
I don't quite know what you are doing as the diagnostic message you posted has nothing to do with the command you posted.

However if you re-read the answer given by RaviRanjankr you should note that the command is javah -jni ClassName , NOT javah -jni ClassName.class.
RaviRanjanKr 29-Dec-10 9:26am    
O my God! you need to learn the basics of java
why are you using HelloWorld.Class?
See my answer [last Line]
I wasted like 3 hours on this. It has been due to some sort of java directory issues or what. Anyways this is how i did it.

Open command line. Go to the exact folder where .java class is located. go there and execute command

Java
javac HelloWorld.java



then go back to the folder containing the complete package. There type this statement for generating the header file from the class file. The directory must be like in my case the whole package was in Java directory file so i went back there and typed the following command.

Java
javah -jni com.example.aliabbasjaffri.temporary.HelloWorld


Voila, Header file at your service.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900