1

Can anyone figure out whats the issue in this command.

i used command for generating is:

-classpath $Classpath$ -v -jni $FileClass$

it throws exception:

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: Files\Java\jdk1.8.0_102\jre\lib\charsets.jar;C:\Program
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:129)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:107)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:64)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:503)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:329)
at com.sun.tools.javah.Main.main(Main.java:46)

MyNDK.class:

public class MyNDK {

// Used to load the 'native-lib' library on application startup.
static {
    System.loadLibrary("MyLibrary");
}

public native int getHelloSum(int[] val,int size);

}

Setting for NDK: NDK SETTING

YLS
  • 1,475
  • 2
  • 15
  • 35
  • 3
    Try to put classpayh in quotes, `"&Classpath&"` – Alex Cohn Oct 20 '16 at 16:35
  • If you already have java class code, and inside android studio, could you use the missingFunctionInspection thing inside Android Studio to let it generate the prototype for you? it is a bit trick to use, but it might save some trouble. One example is inside this: https://codelabs.developers.google.com/codelabs/android-studio-jni/index.html?index=..%2F..%2Findex#3 it used gradle-experimental, but that particular step works for CMake/Ndkbuild too [ no change ]. It should do most of the work for your function, one minor modification is to add extern "C" for hosting cpp file – Gerry Oct 21 '16 at 05:23
  • @AlexCohn in place of $ i have used & with quotes now i am getting this error "C:\Program Files\Java\jdk1.8.0_102\bin\javah.exe" -classpath &Classpath& -v -jni com.myndkapp.MyNDK Error: Could not find class file for 'com.myndkapp.MyNDK'. – YLS Oct 21 '16 at 05:45
  • 1
    My fault; it should be `$` – Alex Cohn Oct 21 '16 at 07:56
  • 1
    Yes it worked @AlexCohn Thanks – YLS Oct 21 '16 at 08:23

1 Answers1

6

@Alex Cohn helped me to fix this the correct answer is :

-classpath "$Classpath$" -v -jni $FileClass$
YLS
  • 1,475
  • 2
  • 15
  • 35