Java.lang.IllegalArgumentException: Invalid class name: ANDROID NDK javah

I am learning Android code in NDK on WINDOWS Eclipse .... followed the Sylvain Ratabouil tutorial. So im in Run | External Tools | External tool configurations ... creating a new program configuration.

Name: MyProject javah

Location: $ {env_var: JAVA_HOME} \ bin \ javah.exe

Working directory: $ {workspace_loc: / MyProject / bin}

The problem arises in the arguments ... when I try Arguments: -d $ {workspace_loc: / MyProject / jni} com.myproject.MyActivity as stated in the book

I get when I click run

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: –d 

when I try $ {workspace_loc: / MyProject / jni} com.myproject.MyActivity}

I get

 Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: C:\Paul\Workspace\MyProject\jni 

UPDATE: At first I put -classpath and it works, but cannot find the class file for com.myproject

+6
source share
6 answers

after further research .... I did it.

i set the arguments

-d $ {workspace_loc: / MyProject / jni} -classpath C: \ Paul \ android-sdk-windows \ platform \ android-17 \ android.jar; $ {workspace_loc: / MyProject / bin / classes} com.myproject.MainActivity

+5
source

I also deal with this issue for a long time while working with the mentioned book about Android NDK.

Please note the following: The java class name is NOT written in { } , just write something like com.myproject.MyActivity

The -classpath parameter can accept multiple paths, separated by a semicolon.

In my case, these options worked:

Location:

 ${env_var:JAVA_HOME}\bin\javah.exe 

Working Directory:

 ${workspace_loc:/myproject/bin} 

Arguments:

 -d ${workspace_loc:/myproject/jni} -classpath ${workspace_loc:/myproject/bin/classes};"C:\Eclipse\sdk\platforms\android-18\android.jar" com.myproject.MyActivity 

(BTW: The correct Adroid.jar file is listed in the Eclipse project.)

+1
source

I also ran into the same problem today, I found a less tedious way to follow ...

  • as "Location", install javah from your system.
  • as the "Working directory" set the bin / classes directory of the project ( $ {workspace_loc: / HelloWorld / bin / classes} )
  • as "Argument" set the jni folder as the output directory and specify the class on which you want to run javah ( -d "$ {workspace_loc: / HelloWorld / jni} com.example.helloworld.MainActivity )

NB :: Don’t forget about the double qoute (") around the output in the third step ( " $ {workspace_loc: / HelloWorld / jni} " )

The full picture is also attached after

All 3 steps in a single picture

+1
source

well in case ...

1-> Goto (cd C: \ Program Files \ Java \ jdk1.7.0_60 \ bin)

2-> C: \ Program Files \ Java \ jdk1.7.0_60 \ bin> javah -jni -classpath F: \ Android_OpenGLES \ FibonacciNative \ Bin \ classes -d F: \ Android_OpenGLES \ FibonacciNative \ jni \ com.example.fibonaccinative. Fiblib

without creating / using an environment variable ...

0
source

YES THAT CORRECTLY will be more abstract

 -d ${workspace_loc:/MyProject/jni} -classpath ${env_var:ANDROID_SDK_HOME}\platforms\android-16\android.jar;${workspace_loc:/MyProject/bin/classes} com.myproject.MyActivity 
0
source

After successful attempt

 javah com.sense.kios.Calculation 

Note. Specify a package name.

If javah is not found as a command and you get

 The program 'javah' can be found in the following packages: * gcj-4.6-jdk * gcj-4.7-jdk * openjdk-7-jdk * openjdk-6-jdk Try: sudo apt-get install <selected package> 

use the direct path for the jdk path, in my case it is /usr/lib/jvm/jdk1.8.0/bin/javah .

0
source

Source: https://habr.com/ru/post/949371/


All Articles