JNI日食Javah自动生成 [英] JNI eclipse Javah auto generate

查看:241
本文介绍了JNI日食Javah自动生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javah来生成头文件。我尝试了以下两种方式,但没有一个对我来说是完美的。



方法1:在bin / classes中,我使用

  javah -jni com.example.test.NativeLib 

它报告:

 错误:找不到'com.example.test.NativeLib'的类文件。 

但它有时适用于我(任何人都知道为什么?)。



然后我使用以下方式也很受欢迎:在src /

  javah -classpath ../bin/classes -jni com.example.test.NativeLib 

它报告:

 错误:找不到类org.opencv.core.Mat。 

然后我添加OpenCV类路径:

  javah -classpath ../bin/classes/:D:/OpenCV/OpenCV-2.4.9-android-sdk/sdk/java/bin/classes -jni com.example.test .NativeLib 

它报告:

 错误:找不到'com.example.test.NativeLib'的类文件。 

再次。



任何人都知道为什么?

解决方案

轻松将您的课程路径指向你的opencv java类存在的地方。 javah在其类路径中需要这个类。


org.opencv.core.Mat


所以,很容易喂它。如果您从官方opencv下载中心下载了opencv4android,并在$ opencv4android中解压缩,那么您会发现这一点。
$ opencv4android / sdk / java / src

   -  $ opencv4android / 
|
|
------ sdk
|
-java
|
- src
|
- org
|
- opencv
|
- android
- calib3d
- core
|
- Algorithm.java
- Core.java
......

- 引擎
- features2d
- imgcodecs
- ml
- objdetect
- 照片
- utils
- 视频
- videoio

FYI,我在Windows 8上使用opencv 3.0.0版本和Android工作室。
,这是整个javah正在寻找的东西。



Windows用户



打开您的终端导航到以下地址


[路径到你的项目] \app\src\main


并写下面的代码行:

  javah -d jni -classpath [路径到你的android sdk] \platforms\ android-19\android.jar; [opencv4android的路径] \sdk\java\src; .. \..\build\intermediates\classes\debug com.example.test.NativeLib 

现在,javah可以访问所有的opencv类。



Linux用户



请注意,在编写类路径中的类时,应该使用以下语句来分隔搜索地址:(冒号)而不是;(分号) )。


Hi I am using javah to generate header file. I tried the following two ways but none of them works perfect for me.

Method 1: In bin/classes, I use

javah -jni com.example.test.NativeLib

it reports:

 Error: Could not find class file for 'com.example.test.NativeLib'.

But it works for me in sometimes (anyone knows why?).

Then I use the following way which is also very popular: In src/

javah -classpath ../bin/classes -jni com.example.test.NativeLib

it reports:

Error: Class org.opencv.core.Mat could not be found.

Then I add the OpenCV classpath:

javah -classpath ../bin/classes/:D:/OpenCV/OpenCV-2.4.9-android-sdk/sdk/java/bin/classes -jni com.example.test.NativeLib

it report:

Error: Could not find class file for 'com.example.test.NativeLib'.

again.

Anyone knows why?

解决方案

Easily point your class path to the place where your opencv java classes exist. javah needs this class in its classpath.

org.opencv.core.Mat

So, easily feed it with this. If you have downloaded opencv4android from official opencv Download center and extracted it in $opencv4android then you will find this. $opencv4android/sdk/java/src

   -$opencv4android/
    |
    |
     ------sdk
           |
            -java
             |
               - src
                 |
                  - org
                    |
                     -- opencv
                        |
                        -- android
                        -- calib3d
                        -- core
                          |
                           -- Algorithm.java
                           -- Core.java
                              ......

                        -- engine
                        -- features2d
                        -- imgcodecs
                        -- ml
                        -- objdetect
                        -- photo
                        -- utils
                        -- video
                        -- videoio

FYI, I'm using opencv 3.0.0 version and Android studio on Windows 8. and this is whole the stuff javah is looking for.

Windows Users

Open your terminal navigate to the following address

[path to your project]\app\src\main

and write the following line of code:

javah -d jni -classpath [path to your android sdk]\platforms\android-19\android.jar;[path to your opencv4android]\sdk\java\src;..\..\build\intermediates\classes\debug com.example.test.NativeLib

Now javah has the access to all of the opencv classes.

Linux users

Note that in writing out the classes in the classpath, you should seperate the search addresses with :(colon) instead of ;(semicolon).

这篇关于JNI日食Javah自动生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆