Page 160 - The Definitive Guide to Building Java Robots
P. 160

Preston_5564C05.fm  Page 141  Tuesday, September 20, 2005  5:13 AM



                                                                                  CHAPTER 5  ■  SPEECH   141



                                  // sample program
                                  public static void main(String args[]) {
                                      TempConvert tc = new TempConvert();
                                      for (int c = 0; c < 101; c++) {
                                          System.out.println("c=" + c + ",f=" + tc.CtoF(c));
                                      }
                                  }
                              }
                            4. Run javah on the compiled .class file. Javah produces C and C++ header files from your
                              native Java class.
                              javah – jni TempConvert



                        ■Note  From your IDE, you can either go to the compiled class path (for example, /bin/com/scottpreston/
                        javarobot/chapter5) or you can specify the class name from path root or a compiled JAR file.



                              The output of the file is shown in Example 5-2.


                              Example 5-2. TempConvert.h
                              /* DO NOT EDIT THIS FILE - it is machine generated */
                              #include "jni.h"
                              /* Header for class TempConvert */

                              #ifndef _Included_TempConvert
                              #define _Included_TempConvert
                              #ifdef __cplusplus
                              extern "C" {
                              #endif
                              /*
                               * Class:     TempConvert
                               * Method:    CtoF
                               * Signature: (F)F
                               */
                              JNIEXPORT jfloat JNICALL Java_com_scottpreston_javarobot_➥
                               chapter5_TempConvert_CtoF
                                (JNIEnv *, jobject, jfloat);
   155   156   157   158   159   160   161   162   163   164   165