Producing header files with javah--where is everything?

Hi everyone,
I need to make my Java program work with some C++ code. I am trying to compile the classes to header files. This is the header file I get after javah-ing the class where I have the native methods I need to get from the C++:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class client_TOMSClient */
#ifndef Includedclient_TOMSClient
#define Includedclient_TOMSClient
#ifdef __cplusplus
extern "C" {
#endif
#undef client_TOMSClient_REQUEST_TYPE_INCIDENTS
#define client_TOMSClient_REQUEST_TYPE_INCIDENTS 3L
#undef client_TOMSClient_REQUEST_TYPE_EVENTS
#define client_TOMSClient_REQUEST_TYPE_EVENTS 4L
#undef client_TOMSClient_REQUEST_TYPE_ROADS
#define client_TOMSClient_REQUEST_TYPE_ROADS 5L
#undef client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_UNDEFINED
#define client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_UNDEFINED 0L
#undef client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_LINK_STATUS
#define client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_LINK_STATUS 1L
#undef client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_SCHEDULED_EVENT
#define client_TOMSClient_TRAVELER_INFO_RESPONSE_TYPE_SCHEDULED_EVENT 2L
/* Inaccessible static: m_tomsClient */
#ifdef __cplusplus
#endif
#endif
It's mainly the /* Inaccessible static: m_tomsClient */ that's bothering me. I have a hunch that my native methods aren't coming up in the .h file since they are described in the class TOMSClient of which m_tomsClient is the first (and only) instance.
So what am I doing wrong? Is there any way to get javah to also "look" at the static members? Or is this doomed from the start, so to speak?

Addendum:
In fact, now that I really look at it, for some reason none of my members, static or otherwise, seem to be mentioned in the .h file. I even did a test run like this:
public class Demonstration
public String publicName;
private String privateName;
public static String publicStaticName;
private static String privateStatucName;
public native void method1();
public native int method2(boolean b, byte by, char c, short s);
public native byte[] method3(byte data[], boolean b[]);
public native String[] method4(int num, long l, float f, double d);
static
System.loadLibrary("Demonstration");
And what I got was this:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Demonstration */
#ifndef IncludedDemonstration
#define IncludedDemonstration
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: publicStaticName */
/* Inaccessible static: privateStatucName */
* Class: Demonstration
* Method: method1
* Signature: ()V
JNIEXPORT void JNICALL Java_Demonstration_method1
(JNIEnv *, jobject);
* Class: Demonstration
* Method: method2
* Signature: (ZBCS)I
JNIEXPORT jint JNICALL Java_Demonstration_method2
(JNIEnv *, jobject, jboolean, jbyte, jchar, jshort);
* Class: Demonstration
* Method: method3
* Signature: ([B[Z)[B
JNIEXPORT jbyteArray JNICALL Java_Demonstration_method3
(JNIEnv *, jobject, jbyteArray, jbooleanArray);
* Class: Demonstration
* Method: method4
* Signature: (IJFD)[Ljava/lang/String;
JNIEXPORT jobjectArray JNICALL Java_Demonstration_method4
(JNIEnv *, jobject, jint, jlong, jfloat, jdouble);
#ifdef __cplusplus
#endif
#endif
Now I am pretty sure that both public String publicName and private String privateName should have shown up in the .h file. What is going on? I'm completely confused.

Similar Messages

  • How to include header files with different extensions

    Hi,
    When i include a header file with extension .ch (myincludefile.ch), the compiler gives error messages but when i change the extension to .h, the problem disappears.
    Can anyone help me getting rid of this problem?
    For example, for the line below, I get a warning such as, "attempt to redefine MY_CONST without #undef". Remember when i change the extension to .h, the problem disappears.
    #define MY_CONST 500 /* Constant */
    Thank you very much

    I don't see how the name of the file could cause or prevent error messages, except when template declarations are involved. So let's assume for now that the file has a template declaration.
    The Templates chapter of the C++ Users Guide explains about including or separating template declarations and their definitions.
    If you have only a template declaration in a file and the compiler needs the definition, it will look for another file with the same base name and include it automatically. For example, if you have files foo.h and foo.cc, and foo.h has a template declaration, the compiler will include foo.cc automatically, even if you didn't intend for that to happen. You can wind up with multiple delcaration errors that way.
    When looking for a file containing template definitions, the compile will not include a .h file, so as not to create recursive inclusion. If changing the file name to .h causes your problem to disappear, it seems like an unwanted automatic inclusion is the problem.
    You can try two things to find out:
    1. Compile with the -H option. The compiler will output an indented list of all included files. See if you are getting a file you didn't intend, or the same file twice.
    2. Compile with option -template=no%extdef. It disables the automatic search for template definitions.
    If you find an unintended included file this way, you will probably have to change the names or organizaiton of some of the files. Our implementation of the C++ standard library depends on NOT using the -template=no%extdef option, which might mean you can't use that option.

  • How to use preprocess​or directives (#define) in C++ header file with LabVIEW 8.2

    I have a C++ header file that contains around 2000 preprocessor directives:
    #define MEM_1   0xC
    #define MEM_2   0xD
    #define MEM_3   0x18
    I want to be able to "access" these memory offsets by identifier name (MEM_1) in my LabVIEW program like I would in a C++ program.  I do not want the overhead of parsing through the header file and storing all the offsets into an array or similar structure. 
    I've written a simple Win32 console program to return the memory offset given the identifier (see code below), and created a DLL to use with my LabVIEW program.  In the console program, you notice that I can call a function and pass in the identifer name, and get the offset back correctly:
    getOffset(MEM_1);
    In LabVIEW, I was hoping to be able to pass in the identifier (MEM_1) but was unsure what datatype to use.  In my C++ code, I defined the parameter as an int.  But in LabVIEW, I can't enter in MEM_1 as an int.   Can someone advise on how to do this?  Or if there is an alternate way to use #define's from external code inside LabVIEW?
    #include "stdafx.h"
    #include "scrmem.h"
    #include "stdio.h"
    void getOffset (int var);
    int _tmain(int argc, _TCHAR* argv[])
     getOffset(MEM_1);
    canf("%d");
     return 0;
    void getOffset (int var)
     printf("The address of MEM_1 is %x", var); 

    kaycea114 wrote:
    Hi,
    Where do you think I should use the string? 
    The way that getOffset is currently defined in the DLL, I have to connect an integer input into the LabVIEW function.  This prevents me from entering in: MEM_1 as the input to the LabVIEW function.
    Are you suggesting that I change getOffset to receive a String parameter ("MEM_1")?  Does that mean I need to do a string compare (line by line) through the header file to get the offset?  It seems like doing this search through the header file would degrade performance, but if that's the only work around, then I'll do it.
    Please advise.
    Well, what you want to do is indeed entering a string and getting back the assigned integer. That is what the C preprocessor is doing too although there it is done only once at the preprocessor stage of course and not at runtime anymore. But LabVIEW is not a C preprocessor.
    What you did so far seems to be to define getOffset() that accepts an enum that needs to be created from the C source code to then return the assigned constant. That's of course not very helpful.
    And writing a VI that could parse the C header file and create a name/constant array is really a lot easier than doing the same in C. You don't even need to parse the file each time again, but can instead cache them in an uninitialized shift register (LV2 style global).
    Even more easy would be to create from that data a ring control using property nodes and save it as custom control and voila you have the most direct lookup you can get in LabVIEW and it works just as comfortable as using the define in C code. It would mean that you need to seperate your header file possibly into several different files to only get related constants into the same ring control, but that is easily done.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Using header files with call library node

    I am writing an application for Palm PDA, and I use call library node to insert some C code written in Codewarrior 9 for PalmOS.
    For some reason, when I build the program for the Palm the builder does not recognise the functions declared in my header files.
    Please help me with this problem and tell me how do I create a header file in Codewarrior so the builder can include it in the Palm application!!!

    Hello
    Can anyone help me out?  I am trying to use a chart with a Sliding Region of intrest function. 
    I would like to be able to zoom in on the RIO and have the ability to zoom back out.
    I would also like to be able to set the initial mid point setting of the RIO slider.  The original file was using the delta T (psec) control to do this.
    I have only been experiementing with this number to see what value works.  If someone could explain what is going on with that control it would help.
    I noticed that when I move the RIO slider to the left all the way the value goes negative, I am not sure if the program stops reading the value
    at zero or not.....
    When you run  the select RIO Rev 4 vi set the DATA COL to PLOT to 1 to see the correct data
    Thanks in advacne
    Tim C.
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
    Attachments:
    Sliding ROI Rev 4.zip ‏111 KB

  • Using Cpp code and header files with LV8 CIN

    Hello,
    I have three pieces of C++ code and their header files that are called from a Main C++ code.  I want to call these from a LV8, code interface node (CIN).  I have the C++ compiler installed on teh same machine as LV8.  My questions are:
    1) How do I call the C++ code anf the header files from the LV CIN?  I have never doen this. Is there a concise manul for this somewhere?  Teh last thing any self-respecting engineer wants to do is read the manual.
    2)  Once I successfully call teh C++ and header files from within the CIN, can I create a LV runtime executable, just as I can with any other LV8 .vi?  Will this runtime .exe run stand-alone as a distribuatble application?  Do I need to include any special runtime files when I build the exectuable to support teh C++ code?
    Thank you.

    http://forums.ni.com/ni/board/message?board.id=231&message.id=2424&requireLogin=False
    handles your question.

  • Header file WITHOUT javah..

    Hi,
    i searched the web but didn't found anything. Is there any kind of 'specification' how to get the declaration of the native method implementation in C just from the declaration of the native method declaration in java?
    thanks :-)

    Hi
    if you dont want to use the JAVAH tool to generate the C header files , you can do it your self.
    The fucntion should have the the follwing signature:
    1) for member function
    JNIEXPORT jobject JNICALL Java_<PACKAGE NAME>_<CLASS NAME>_<METHOD NAME>
    (JNIEnv *env,jobject obj)2) For Static functions
    JNIEXPORT jobject JNICALL Java_<PACKAGE NAME>_<CLASS NAME>_<METHOD NAME>
    (JNIEnv *env,jclass obj)regards
    pradish

  • [solved] Joining 3gp files with same aspects and everything

    Hi!
    I am using archlinux and for watching movies I use mplayer.
    When I record movies with my mobile they are in the format .3gp.
    Sometimes I record or recive through mms smaller movie clips in a series.
    I want to join them together to one .3gp file with the same quality and all.
    I have been looking for a good help for doing this on the web but so far haven't found anything.
    If anyone can help me how to join multiple .3gp files into one .3gp file I would be glad...
    Last edited by XeroXer (2007-05-28 18:59:57)

    got an error saying that I should use -oac pcm for the sound.
    tried that and the sound merged great but not the video.
    it got a lot messed up and when I try to fastforward in the movie it ends the mplayer.
    so it worked partly...
    with -oac copy
    MEncoder 1.0rc1-4.1.2 (C) 2000-2006 MPlayer Team
    CPU: Intel(R) Celeron(R) M processor 1.40GHz (Family: 6, Model: 13, Stepping: 8)
    CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
    Compiled with runtime CPU detection.
    98 audio & 216 video codecs
    WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
    success: format: 0 data: 0x0 - 0x4898d
    ISO: File Type Major Brand: 3GPP Profile 5
    Quicktime/MOV file format detected.
    VIDEO: [s263] 176x144 24bpp inf fps 0.0 kbps ( 0.0 kbyte/s)
    [V] filefmt:7 fourcc:0x33363273 size:176x144 fps: inf ftime:=0.0000
    videocodec: framecopy (176x144 24bpp fourcc=33363273)
    Audio format 0x726d6173 is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.
    Exiting...
    RESULT:
    The suggestion I got ended up with a movie with great sound but bad picture. The movie can not be skipped in sections because then mplayer just quits.
    Last edited by XeroXer (2007-05-28 13:59:01)

  • How to produce folio files with 5.5?

    After combing through these forums to understand the differences between 5.5 with and without DPS, I was under the impression that I could produce a folio file using 5.5, but without having to invest in DPS by saving the folio to an acrobat.com account. I went ahead and upgraded, but now when attempting to produce a folio file, it asks me to log in to DPS. Am I missing something, or is Adobe really that ******?
    I'm at a non-profit university, and we want to be able to produce interactive presentations for the ipad, but cannot afford DPS prices for something that will be uploaded to only one device.

    The Adobe Digital Publishing Suite has its own forum where you can get a better answer:
    Digital Publishing Suite
    One of our regular members, Bob Levine, is active in that forum but he's temporarily away so your best bet is to go to the linked forum.

  • Problems creating packaged .h files with javah -jni

    I have all of my .java and .class files in package ClassLib.Satrack.
    My directory structure is C:/SatrackIIP/NavComponent/ClassLib/Satrack.
    I compiled all java files by calling javac ClassLib/Satrack/*.java from NavComponent directory. Then still from NavComponent directory, I call javah -jni ClassLib/Satrack/TrajectoryGenerator. However I am getting an error message:
    Error: Class ClassLib/Satrack/TrajectoryGenerator could not be found.
    Why am I getting this error?

    Fixed it. I should be calling javah -jni ClassLib.Satrack.TrajectoryGenerator and not using dashes in between.

  • Pls help - produce xml file with an agreed-upon DTD

    I posted this a few weeks ago:
    I have only installed XSU, and I was hopping to use pl/sql package XMLGEN to generate XML with a given DTD and a sql query.
    I can't find input parameter for DTD. Well it seems logical as both DTD and SQL are for defining the XML output file.
    How can this be done ?
    Thanks.
    /Kwan
    Do I need to process the DTD to generate Java classes ? and then create XML document by a java application ?
    I am in a pl/sql shop and I am not eager to go java because I need to use a DTD.
    comments / help ?
    thanks.
    /Kwan
    I am in a pl/sql shop

    Cross-post: http://forum.java.sun.com/thread.jspa?threadID=784467&messageID=4459240#4459240

  • Produce XML file with a given DTD

    I have only installed XSU, and I was hopping to use pl/sql package XMLGEN to generate XML with a given DTD and a sql query.
    I can't find input parameter for DTD. Well it seems logical as both DTD and SQL are for defining the XML output file.
    How can this be done ?
    Thanks.
    /Kwan

    Sure. You could write an EntityResolver to do that. Attach it to your DocumentBuilder or XMLReader, depending on which you are using.

  • Problem in compiling C file with JNI

    Hello to all,
    I have a simple JNI tutorial
    But after creating the header file using "javah -jni " command when I use that header file in to the C implementation it gives error
    Following code is of HelloWorld.cpp in which the header file in included
    #include <stdio.h>
    #include "HelloWorld.h"
    JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)
         printf("Hello World!\n");
         return;
    }The error is
    line number 2 - Unable to open include file "HELLOWORLD.H"
    line number 4 - Declaration syntax errorMy java file "HelloWorld.java" is
    class HelloWorld
         private native void print();
         public static void main(String[] args)
              new HelloWorld().print();
         static
              System.loadLibrary("HelloWorld");
    }I also after coping the file into the include directory of the TurboC but same error arise.
    Please suggest me what to do.
    Thanks in advance

    Yes I used "javah -jni HelloWorld" command after complying the program.
    It produced a header file which I have placed in the same directory in which my project is. Then the same error comes, when I place it in include directory of TurboC give same error.

  • Problem related to generation of header file

    hi guys,
    I am getting Exception during the generation of the header file,
    using "javah -jni HelloWorld"
    I am refering jni.pdf (java.sun.com/docs/books/jni/download/jni.pdf )
    I have given that error below
    Exception in thread "main" java.io.IOException: can't find class file HelloWorld.class in java.net.URLClassLoader
    {urls=[file:/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre/lib/rt.jar],
    parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:./],
    parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
    at gnu.classpath.tools.javah.Main.getClass(libgcj-tools.so.8rh)
    at gnu.classpath.tools.javah.Main.run(libgcj-tools.so.8rh)
    at gnu.classpath.tools.javah.Main.main(libgcj-tools.so.8rh)

    ejp wrote:
    GCJ is what you get in Linux (definitely Ubuntu anyway) as the default Java implementation.GCJ isn't a Java implementation at all, as you will discover when you read its documentation attentively. This is because it doesn't pass the Java certification tests. Ergo whatever it may be it isn't Java.
    This is because of the license for Java not being compatible with the Ubuntu distro license.That may be so, or have been so, but it still isn't Java.I guess if you want to label it, it is the GNU Compiler for Java and associated runtimes. As an open source project for when Java licensing was not very compatible with Linux it served a purpose (even if it served it badly).
    The following is from the GCJ web site. I guess they don't really claim to be 100% Java compliant.
    GCJ is a portable, optimizing, ahead-of-time compiler for the Java Programming Language. It can compile Java source code to Java bytecode (class files) or directly to native machine code, and Java bytecode to native machine code.
    Compiled applications are linked with the GCJ runtime, libgcj, which provides the core class libraries, a garbage collector, and a bytecode interpreter. libgcj can dynamically load and interpret class files, resulting in mixed compiled/interpreted applications. It has been merged with GNU Classpath and supports most of the 1.4 libraries plus some 1.5 additions.The first step for me with Linux was always to install the Sun JDK so never really found out how bad it really was :)
    Cheers,
    Shane

  • How to save a Photoshop PDF file with fonts that can be detected in Acrobat?

    We created a PDF file using Photoshop CS5, for the purpose of using it as a watermark on documents.  We saved this file as Photoshop PDF file, but for some reason the fonts cannot be detected when the file is opened in Adobe Acrobat.
    We need it to be recognized by Acrobat so that we can easily add the watermark to documents on a regular basis.
    Right now, Acrobat cannot detect the fonts in this file -- even though it is a basic font like Arial -- so when we add the watermark to a document, the fonts in the watermark becomes very degraded in appearance.
    Any advice would be hugely appreciated!

    I've tried several settings when saving as a PDF, to try to produce a file with fonts that can be detected by Acrobat.  I tried the presets listed in guide: Photoshop Help | Saving PDF files
    But none have worked.
    I cannot use PNG because it is not one of the formats that Acrobat allows for a watermark.  And JPG doesn't work because I need transparency.

  • Header file

    I need to create a header file with the following specifications
    FILLER IS CREATED BY SPACING THROUGH THE FIELD FOR THE APPROPRIATE SIZE OF THAT FIELD. A FILLER SIZE OF ONE WOULD REQUIRE THE CURSOR BE ADVANCED BY ONE SPACE
    USING THE SPACE BAR. FIELD #3 REQUIRES 841 SPACES BE CREATED USING THE SPACE BAR. ONLY ENTERING SCHOOL YEAR, HEADER-NUMBER-RECORDS, RECORD-MARK, AND THE
    APPROPRIATE HEX CHARACTERS AND NOT SPACING THROUGH THE NEXT 841 POSITIONS DOES NOT PROPERLY CREATE FILLER FOR FIELD #3 AND WILL CAUSE THE SUBMISSION FILE TO
    FAIL TO LOAD.
    I am using this code and the file keep failing in the header rcord
    set verify off
    set echo off
    ----set pagesize 9999
    set wrap off
    set heading off
    set trimspool on
    set linesize 9999
    column    school     format a1;
    column    totals     format a5;
    column    spaces1    format a841;    
    spool header.lst
    select
    '0'       school,
    '02264',
    rpad(' ',841) spaces,
    CHR(13)||CHR(10)
    from
    dual
    position   end   size
    1              1        1
    2              6        5
    7             847   filler
    848        848      1         '\'
    849        849      1    ASCII carriage return
    850        850      1    linefeed
    {code|
    I create the file in unix ftp and copy and paste in the file,
    Any help will be appreciate
    Edited by: user648177 on Apr 16, 2009 1:50 PM
    Edited by: user648177 on Apr 16, 2009 1:51 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    "why in Micro soft visual studio the .h extension has been removed from <iostream.h> ? And why they defined cin and cout in namespace standard c++ library although they are already defined in <iostream.h> header file ?"
    Because it's non standard, the standard version is called <iostream>
    "why getch(); function which is defined in <conio.h> header flie is not working in visual studio ?"
    It works but it's called _getch instead of getch. Likely because it's non-standard as well.
    "BGI is not working in visual studio ?"
    VC++ doesn't come with a BGI library. But if you search the Internet you may be able to find BGI implementations that work in VC++/Windows. This perhaps:
    http://openbgi.sourceforge.net/

Maybe you are looking for