Jni Example in Eclipse - java-native-interface

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

Related

Different FS roots (docker vs. host env) and navigation from compilation error paths in Terminal

I am using vscode for my development with C++ and docker (Linux) and I have an issue with my compilation-to-code-editing work cycles.
Namely, I get errors with paths like this from the compiler:
In file included from **/rootsrc/myproj/test.cpp:33**:
<here is some error description>
And now if I hold Ctrl and left mouse-click on the file reference, vscode has no idea where that file is and gives me an error "No matching result".
Is there some way to set vscode up such that this plugin (or whatever it is) that is responsible for navigating from path links in the Terminal "knows" that it should first cut off the docker base dir and then prepend my host dir before resolving the path link?
Thanks in advance :)

QwtPlot3D build on Windows

I downloaded QwtPlot3D project from here
https://sourceforge.net/projects/qwtplot3d/files/
When I run qmake on the project file in the zip, I get following result:
WARNING: Unable to generate output for: C:/path/Makefile.Debug [TEMPLATE vclib]
QIODevice::write: device not open
Same when I try to build from QtCreator.
Any ideas ?
Thank you very much.
You are creating the file in a location that does not exist on the computer.
You could change the location of the folder to be created.

Error while building WSO2 Microgateway project on Windows 10

I’ve been trying to explore WSO2 Microgateway and set up a Microgateway project. Building the project in Windows 10 with the command “micro-gw build project-name” is giving this error: “Could not find or load main class org.wso2.apimgt.gateway.cli.cmd.Main”.
I’ve downloaded the Toolkit and Runtime from https://wso2.com/api-management/api-microgateway/. I've set the Path environment variable to the /bin directory of the Toolkit and Runtime extracted folders, but still the “micro-gw build project-name” command is giving error “Could not find or load main class org.wso2.apimgt.gateway.cli.cmd.Main”. I’ve also cloned the source code from Github (https://github.com/wso2/product-microgateway/) which has the Main.java class and tried setting environment variables to its path.
I also tried setting the environment variables to the path where Toolkit batch file is present. I also followed the steps mentioned here, https://github.com/wso2/product-microgateway/#running-the-microgateway.
I'm assuming the Toolkit batch file (micro-gw) would execute the Main.java class coming up in the error.
These steps did not resolve the error. I'm new to Java based product, and I'm sure I'm missing something here.
Problem is with the init command not the build command. Init command is suppose to setup the TOOLKIT after the first use. It should extract the platform.zip file and copy all of the required resources to relevant places for you.
I hope you get the Project ___ successfully initialized message after running the init command. Just check $TOOLKIT_HOME/logs/ directory to see if there are any information on the log file.
If the log file also doesn't help, as a workaround, copy all the .jar files inside $TOOLKIT_HOME/lib/gateway/platform and $TOOLKIT_HOME/lib/gateway/cli to $TOOLKIT_HOME/lib/platform/bre/lib and try again, that should work.
Also please report this issue at https://github.com/wso2/product-microgateway/issues

Javah error, cannot find class file

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.

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.