Using C functions with JNI

Hello,
I am just looking at JNI for the first time today. I have to write some utility functions in C for the a linux Red Hat 7 server, and then be able to call them from java applications. I am having some trouble when I try and compile the c source. I am not sure if this is a C error directly, or caused by the java. I am really sorry if this is a C error, its been awhile! I am simply trying to runt the demo on the java.sun.com site. Here is my code:
The Java:
public class HelloWorld {
public HelloWorld() {
public native void displayHelloWorld();
static {
System.loadLibrary("hello");
public static void main(String[] args) {
new JNITest2().displayHelloWorld();
The c file:
#include <jni.h>
#include "JNITest2.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
printf("Hello world!\n");
return;
The .h file:/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef IncludedHelloWorld
#define IncludedHelloWorld
#ifdef __cplusplus
extern "C" {
#endif
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()V
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
#endif
#endif
The Error I Get:
[2943UK@hercules classes]# cc -g -I/usr/local/jdk1.3/include -I/usr/local/jdk1.3/include/linux HelloWorldImp.c -o libhello.so
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o: In function `_start':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
Thanks in advance to anyone who knows the answer and can help me.
Ian

Sorry, Here is the java source I am using:
public class HelloWorld {
public HelloWorld() {
public native void displayHelloWorld();
static {
System.loadLibrary("hello");
public static void main(String[] args) {
new HelloWorld().displayHelloWorld();
}

Similar Messages

  • Creating Report using EPM Functions with Dynamic Filters

    Hi All,
    I am new to BPC, In BPC 7.5 i seen like we can generate EPM report using EVDRE function very quickly and easy too. Is the same feature is existing in BPC 10.0 ? if no how can we create EPM reports using EPM Functions with Dynamic Filters on the Members of the dimension like in BPC 7.5.
    And i searched in SDN, there is no suitable blogs or documents which are related to generation of Reports using EPM Functions. All are described just in simple syntax way. It is not going to be understand for the beginners.
    Would you please specify in detail step by step.
    Thanks in Advance.
    Siva Nagaraju

    Siva,
    These functions are not used to create reports per se but rather assist in building reports. For ex, you want to make use of certain property to derive any of the dimension members in one of your axes, you will use EPMMemberProperty. Similary, if you want to override members in any axis, you will make use of EPMDimensionOverride.
    Also, EvDRE is not replacement of EPM functions. Rather, you simply create reports using report editor (drag and drop) and then make use of EPM functions to build your report. Forget EvDRE for now.
    You can protect your report to not allow users to have that Edit Report enabled for them.
    As Vadim rightly pointed out, start building some reports and then ask specific questions.
    Hope it clears your doubts.

  • Using modular functions with movieclips

    hi guys, this morning i was looking a tutorial that shows how to make modular functions, the user only used numbers, i was wandering if there is a way to use this with movieclips or childs.
    The example was:
    function addNumber(num1:Number,  num2:Number,  num3:Number):void
    trace(num1+num2*num3);
    addNumber(3, 4, 7);
    i tried using a movieclip called cuadro and triying to move on the x axis, but it didnt work out:
    function mObj(obj1:MovieClip,  num1:Number):void
    obj1.x = num1;
    addNumber(cuadro, 50);
    any sugestion?
    thnks in advance

    oh sorry my bad, i was trying another stuff
    i know that the last line must say
    mObj(cuadro, 50);
    what im trying to do is use the function with some objects in the stage, and for example when i press the first button, it will write mObj(cuadro1, 50) , button2  mObj(cuadro2, 80), so i can use the same function for diferents objects

  • Using Multiple Functions with in members selection of Hyperion Financial St

    Hello everyone, I am trying to retrieve all the level 0 entity members from a specific Level 3 entity member. Can I use multiple Functions with in Report studio to do this?? Or is creating an alt hierarcy my only option?
    Thanks

    You can try doing System Defined member list Lev 0 AND Descendants of Lv 3 member
    JTS

  • How to use aggregate function with Date

    Hi All,
    I have a group of date from that is it possible to Max and Min of date.
    I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>.
    I have also tried like this but it doesnt works
    <?xdoxslt:minimum(CREATION_DATE)?>
    Is it possible to use aggregate function with date values.
    Thanks & Regards
    Srikkanth

    Hi KAVI PRIYA,
    if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
    please advise me,
    Thanks,
    Sri

  • How to use TRUNC function with dates in Expression Builder in OBIEE.

    Hi There,
    How to use TRUNC function with dates in Expression Builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
    Thanks in advance

    use this instead:
    TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE)

  • How can I use AGO function with aggregates

    I use aggregated table and a detailed table
    I have time hierarchy whose lowest level is date. For sales I
    created year-to-year (YTD) comparision with AGO function. It
    works OK.
    BUT, I want to speed it up, so I used aggregates. I created new
    time table grouped by MONTH and corresponding agg_SALES table. I
    created connections and mapped the fields. It works OK for
    normal queries, that means my queries at month level use
    aggregates. BUT when I add YTD measures or YAGO measure in query, it goes to
    then SALES table whose grain is date.
    How can I force BI Server to use AGO function with aggregates?
    I use OBIEE 10.1.3.4
    Thank you
    Ishaq
    (Question originally taken from ITtoolbox and posted by Gorazd)
    SORRY - THE QUESTION IS IN THE WRONG FORUM
    Edited by: ishaq12 on Nov 19, 2008 12:21 PM

    Hi,
    you can not do it in Administration tool but you can set agregation for that field in Answers (fx->Agregation rule->Sum) and effect should be the same. Note that it may not work properly on Oracle 10g as generated SQL is not 100% recognized, on 11g everything is OK (at least in my case).
    Regards,
    Marko
    Edited by: user10449532 on 2008.11.19 06:29

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • C++: Is it possible using callback function with ncacn_http and rpcproxy server ?

    I have a remote procedure and I can call it using http over rpc. I pass trough an rpc proxy server for arriving to my rpc server.
    But I cannot call a callback function to my client inside the server function.
    Is it possible using callback function with ncacn_http and rpcproxy server ?
    We are using IIS on windows server 2008 R2 and the server rpc and the client on the same PC with rpc rpoxy.
    If I use ncan_ip_tcp all works fine.
    Thanks
    Gianluca

    Hi,
    About the develop question please post to the MSDN forum.
    MSDN forum Developer Network
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=WAVirtualMachinesVirtualNetwork&filter=alltypes&sort=lastpostdesc
    Thanks for your understanding and support.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Use private function with interface

    I'm working with ActionScript 2 and wanted to use an
    interface for one of my classes. However, the functions that it
    would define should be private in the classes that implement the
    interface. The problem is that I can't define private functions in
    the interface, and if I leave off any scope in the interface
    ("function findAndSetInformation():Void;") and make it private in
    the implementing class ("private function
    findAndSetInformation():Void {...") I get the error: "The
    implementation of the interface method doesn't match its
    definition.

    WHATS UP ?? WHERE IS TEH MODERATOR ?!!!!
    NO REPLY TELL NOW !!!!
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Yh:
    hi,
    how can i used REPLACE function with LOB database item????!!!1<HR></BLOCKQUOTE>
    null

  • Problem using DECODE() function with a Query of Queries

    I
    posted
    on my blog about an issue I was having trying to use the PL/SQL
    DECODE() function with a Coldfusion Query of Queries. This function
    works fine when you query a database for information. However, when
    you query another query, it seems that CF doesn't recognize it. I
    got errors stating that it found a left parenthesis where it
    expected a FROM key word. Here is a simplified version of what I am
    trying to do:
    quote:
    <!--- Simulated query; similar to what I was calling from
    my database --->
    <cfscript>
    qOriginal = queryNew("Name,Email,CountryCode",
    "VarChar,VarChar,VarChar");
    newRow = queryAddRow(qOriginal, 5);
    querySetCell(qOriginal, "Name", "Joe", 1);
    querySetCell(qOriginal, "Email", "[email protected]", 1);
    querySetCell(qOriginal, "CountryCode", "AMER", 1);
    querySetCell(qOriginal, "Name", "Sally", 2);
    querySetCell(qOriginal, "Email", "[email protected]", 2);
    querySetCell(qOriginal, "CountryCode", "AMER", 2);
    querySetCell(qOriginal, "Name", "Bob", 3);
    querySetCell(qOriginal, "Email", "[email protected]", 3);
    querySetCell(qOriginal, "CountryCode", "ASIA", 3);
    querySetCell(qOriginal, "Name", "Mary", 4);
    querySetCell(qOriginal, "Email", "[email protected]", 4);
    querySetCell(qOriginal, "CountryCode", "EURO", 4);
    querySetCell(qOriginal, "Name", "John", 5);
    querySetCell(qOriginal, "Email", "[email protected]", 5);
    querySetCell(qOriginal, "CountryCode", "EURO", 5);
    </cfscript>
    <cfquery name="qCountries" dbtype="query">
    SELECT DISTINCT(CountryCode) AS CountryCode,
    DECODE(states, "AMER", "North America &amp; Canada",
    "EURO", "Europe &amp; Africa", "ASIA", "Japan &amp;
    Asia","") CountryName
    FROM qOriginal
    ORDER BY CountryCode
    </cfquery>
    <cfdump var="#qCountries#">
    <!--- ========== END OF CODE ========== --->
    So running this returned the following error:
    Query Of Queries syntax error.
    Encountered "(. Incorrect Select Statement, Expecting a
    'FROM', but encountered '(' instead, A select statement should have
    a 'FROM' construct.
    Does anybody know why this doesn't work? Is it just not
    supported? Please note that I have also tried to use the CASE()
    function instead of DECODE() and that resulted in basically the
    same error. For now I an looping over my distinct query with a
    switch statement and manually loading a new query with the data how
    I want it. But it would be a lot cleaner and less code to have the
    DECODE() to work. Thx!

    DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
    very limited subset of SQL and lacks many functions and clauses
    available in standard SQL, especially what you may be used to using
    in your particular RDBMS.
    See
    Query
    of Queries user guide
    Phil

  • Using EveryNCallback function with a C++ class (not VB)

    Hello all,
    I am trying to incorporate one of the ANSI C examples into my code which contains C++ classes. I receive errors because of having to declare the EveryNCallback and DoneCallback functions as static to keep their C function signature. This of course is not allowable when using these functions as members of a class. Could anyone help please?
    Best,
    Paolo

    Firstly, thank you for the help. I have attempted to code the advice you gave but it still does not seem to compile properly. Can you suggest what is wrong with my code please?
    Here is the code I am trying to configure:
    forceDriver.h
    static int32 CVICALLBACK static_callback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void* callbackData);
    int32 EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples);
    int32 DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
    forceDriver.cpp
    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,2500,0,&forceDriver::static_callback,panel));
    **START TASK**
    int32 forceDriver::EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples)
           panel->(member_function);
    int32 CVICALLBACK forceDriver::static_callback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void* callbackData)
    forceDriver* static_object = static_cast<forceDriver*>(callbackData);
    return static_object->EveryNCallback(taskHandle, everyNsamplesEventType, nSamples);
    where panel is the object I have created. 

  • How to use trignometric functions with MIDP1.0

    HI ALL!
    We designed midlet to run on a mobile phone using MIDP1.0. We have some additional trignometrical classes to integerate with the midlet. But we got astonished when we didn't find any trignometrical function in MIDP1.0 & CLDC1.0. It is now is a great panic for us.
    It is very unbelievable that Sun Microsystem doesn't provide such classes with J2ME!!
    Is there any way to define or get a free-ware trignometrical classes to use?
    We hope reply from this Forum soon!

    Mmmm....,J2ME currently doesn't support doubles,floats and if you want to use trigonometric functions then you will use cos, sin, tan, ctan,atan,acos,asin and this means doubles and floats....

  • Using Javascript Functions with Flash 8

    I wanted to know how to integrate Javascript functions with
    Flash 8 created swf files. I assume this would be done using
    ActionScript, I know some ActionScript but am not as familiar with
    it as to be able to integrate other programming languages with it.
    I'd like to be able to call other programming language functions
    with my swf files.
    The particular case I'm working on now is to be able to open
    Pop-Up windows for display of web items from within links written
    in ActionScript in a swf file. In other words, have the user click
    a link in a Flash movie and open a window using a Javascript
    window.open function that would be called. I would like the window
    to contain more flash movies that contained further links to
    functions. If any one could offer up some advice or point me to a
    few tutorials and how tos on how to get the Flash part of this done
    I'd appreciate it.
    In a broader scope, a seemless workflow linking Flash output
    files to outside scripting and programming functions would be nice
    to know if anyone has links or input on where I can read up on
    this.
    Thanks

    myButton.onRelease = function () {
    getURL("javascript:myFunc('myVars')");
    }

  • How to use analytic function with aggregate function

    hello
    can we use analytic function and aggrgate function in same qurey? i tried to find any example on Net but not get any example how both of these function works together. Any link or example plz share with me
    Edited by: Oracle Studnet on Nov 15, 2009 10:29 PM

    select
    t1.region_name,
    t2.division_name,
    t3.month,
    t3.amount mthly_sales,
    max(t3.amount) over (partition by t1.region_name, t2.division_name)
    max_mthly_sales
    from
    region t1,
    division t2,
    sales t3
    where
    t1.region_id=t3.region_id
    and
    t2.division_id=t3.division_id
    and
    t3.year=2004
    Source:http://www.orafusion.com/art_anlytc.htm
    Here max (aggregate) and over partition by (analytic) function is in same query. So it means we can use aggregate and analytic function in same query and more than one analytic function in same query also.
    Hth
    Girish Sharma

Maybe you are looking for