Javah error, cannot find class file - java-native-interface

When I tried to use javah to generate header files, I get this error:
Error: Could not find class file for 'HelloWorld'.
Here is my External tools configuration.
Location: ${system_path:javah}
Working Directory: ${workspace_loc:/JniJava/bin/sonyraj}
Arguments: -jni HelloWorld

Try from the commnnd line/ terminal. maybe javah needs the full path to it? And without packages.
Or fully qualified package name as noted here Javah error while using it in JNI
javah -jni com.example.JavaHowTo
where com.example is your package.
You also need to run javah from the directory containing com/example/JavaHowTo.class
e.g. if your structure is
/home/user/project/Iot/com/example/JavaHotTo.class
run javah from
/home/user/project/Iot

I also had the same problem, try to put your .class files in a folder with the same name as the package name. Then run "javah packagename.ClassName". Hope it works for you too.

Related

LNK1181 Error while compiling the core after adding a module

I'm trying to compile my core with some modules but i'm getting the following error when building worldserver:
cannot open input file '..\..\..\modules\RelWithDebInfo\modules.lib' worldserver
This error only happens when compiling with the mod-gain-honor-guard module. I've installed a repack before that came with this module pre-installed, which makes me think that i'm the one missing something.
Any ideas?
Thanks!
I've compiled the core succesfully with only one module, then i've added the one mentioned before and that error came up. CMake didn't show me any error when i regenerated the source for building after adding the module
You always need to regenerate the source in CMake when you add or remove any files to the source.
Did you get the module via git clone? If not, and it's a direct download, you need to remove the -master or any other branch name from the folder name.

Include Path location for xerces C++

I'm trying to build xerces in Ubuntu. I am getting a file not found error with one of the headers. This is a basic question but how does the compiler know the location of xercesc? I have defined XERCESROOT, does it use that?
#include <xercesc/dom/DOMLSInput.hpp>
https://xerces.apache.org/xerces-c/program-dom-3.html
The compiler knows the location of the header files based on the build configuration. In gcc it is possible to define the header directory through -I flag (e.g. -I/usr/local/include).
In order to check which directory the compiler is looking for your header file see the string showing the last compiler command before the error.
You have to find something like gcc -I etc... where directory is the directory where it is searching.
Anyway, I've just compiled xerces-c-3-1-3 from command line on my Ubuntu 14.04 LTS without defining XERCES_ROOT using the following steps:
Download from this site
tar zxvf xerces
./configure
make
and it works without error.

Understanding of usage of Java2Wsdl for axis2/c

I have a problem with the installation of Java2Wsdl tool.
I have succesfully created and compiled(generated the .class file from the .java file) a simple Java class inside a directory /home/user/examples/com/mycompany/app.
In there I compile my SimpleClass and so, I have two files: SimpleClass.java & a SimpleClass.class .
Next, I have axis2/c installed on my ubuntu system
$ echo $AXIS2C_HOME
/usr/local/axis2c
I also have axis2/java installed
echo $AXIS2_HOME
/opt/axis2-1.6.2
I also downloaded, extracted and installed from this link the java2wsdl plugin.
This is how the bin directory looks like.
username#usernamePC:/opt/axis2-1.6.2/bin$ ls
axis2.bat axis2server.sh java2wsdl.bat setenv.sh wsdl2java.sh
axis2server.bat axis2.sh java2wsdl.sh wsdl2java.bat
Now, I want to convert my initial project from java to wsdl with java2wsdl but I cannot understand the right place of directory I should put that into, if I have the classpath(?) right and what would be the correct command for the conversion to happen.
I am trying something like that: Java2WSDL.sh -cn com.mycompany.app.SimpleClass
In here I put . instead of / and I am typing that in top directory, meaning com directory.
Can you help me out with this?
I am sorry for the long question but I needed to set all things right.
my-app was build with a simple maven project (maven 2.2.1) through this guide.
You should start codegeneration from build/classes directory.
That directory must have com and META-INF subdirs.
Example of generating WSDL:
# compile your project using ant or mvn
ant
# go to binary dir
cd build/classes
# check SimpleClass.class is here
ls com/mycompany/app/SimpleClass.class
# generate WSDL into current directory
$AXIS2_HOME/bin/java2wsdl.sh -cn com.mycompany.app.SimpleClass
# see generated WSDL
cat SimpleClass.wsdl
To generate WSDL into different directory append -o <directory> switch to command line of wsdl2java.sh script.

Trouble to generate header file for JNI

I compiled HelloWorld.c successfully. I changed to the directory where HelloWorld.class is.
And I typed javah -jni HelloWorld in Terminal to get header file. I have the following error message. What is the problem? I am developing Android app using Mac OSX.
error: cannot access HelloWorld
bad class file: ./HelloWorld.class
class file contains wrong class: Test.HelloWorld
Please remove or make sure it appears in the correct subdirectory of the classpath.
com.sun.tools.javac.util.Abort
javadoc: error - fatal error
2 errors
I guess that your HelloWorld.class is located in a subfolder Test. You are not expected to be INSIDE that folder but in the ROOT folder for your compiled package(s). So go out of that Test folder and try again javah -jni Test.HelloWorld
BTW i don't understand how you could "compile your HelloWorld.c succesfuly" if you don't even have the header yet. But i am answering what have been asked.

Jni Example in Eclipse

Hi while trying out jni example in this link http://wendro.blogspot.com/2010/03/jni-example-eclipse-dev-cpp.html?showComment=1309930446765#c5048550711511727724
with eclipse Helios windows xp am getting this error in eclipse console
"error: cannot access MyFirstWrapper,
class file for MyFirstWrapper not found,
javadoc: error - Class MyFirstWrapper not found.
Error: No classes were specified on the command line. Try -help."
what i have to do..???
Alternatively, set your run configuration's Working Directory to the project's bin. in the arguments, set flag -d to change where the output file goes to your cpp folder. For example:
Working Directory: ${workspace_loc:/ProjectRoot/bin}
Arguments: -d ${workspace_loc:/ProjectRoot/cpp} full.package.name.path.to.Class
Hi Thanks i only got the answer
i did like this i got a jni header file generated inside cpp folder
In Eclipse Run Tools, External Tools Configurations,
Name:Jni
Location:My javah.exe location
D:\ProgramFiles\Java\jdk1.6.0_17\bin\javah.exe
Working Directory: my javah file location
${workspace_loc:/jni_hello_world/cpp}
And the most important point is inside Arguments we have to give first as our .class location then jni command like below
-classpath E:\Workspace\JNI\jni_hello_world\bin
-jni MyFirstWrapper