Skip to content
Search

Javah

lastmod 2025-02-15created 2020-09-092 edits

Synopsis

The basic form is as follows. Note that when passing a class as an argument, you enter the class path, not the file path.

$ javah [OPTION] [CLASS] [CLASS] ...

Example

To pass the your.practice.android.jni.String class, pass it as follows.

javah your.practice.android.jni.String

Options

-classpath [PATH]
Sets the path from which class files (.class) are loaded.
-o [FILE]
This option lets you set the output file.
-jni
Outputs a JNI-style header file. (default)

Basic form of the Java class

Write the class as follows.

package android.jni

// 공유 라이브러리를 로드하고 함수를 호출할 메서드 선언해야 한다.
public class JniTestClass
{
    // 라이브러리를 로드한다.
    // prefix: lib와 suffix: .so 는 제외한 파일이름을 적는다.
    // ex) LibraryFile를 적을 경우 libLibraryFile.so 파일을 불러온다.
    static {
        System.loadLibrary("LibraryFile");
    }

    // 호출할 메서드를 선언한다.
    // native를 접근지정자 뒤에 붙인다.
    public native String getJniTestString();
}

See also

author Zer0 sitemap