Can I call a C function from Java (using JNI) ??

hello,
I need to call one C function from remote device and get its return value(o/p) (for my application it is device SSID ) and display in the client PC.
Is it possible in java without using SNMP connction?.
please give me idea about it.
I need this information as soon as possible.
Thank you.

see JNI...
basically declare a native method in your java class, then run javah on the class thus generating a *.h file. Then implement the c/c++ function. Compile the c/c++ part as a shared library, and make sure its accessible from your LD_LIBRARY_PATH env variable.
Go through the steps in the JNI docs, and things shoulde be fine... hopefully ;)

Similar Messages

  • How can I call a plsql function from an attribute?

    I have an attribute defined in an element. I want execute a PLSQL function from the attribute, and display the returne value with an HTML template.
    I've defined the attribute's type like PLSQL, and I've put the called of the function in the value of the attribute, but it doesn't work. The only value I obtain is an URL (I think that is the URL of the function or someting like this).
    How can I call to my function from the attribute and display the returnes value in the page?
    Thanks.

    Thanks, but it doesn't work. I have an attribute called ID_BOL and I want to associate a sequence to that attribute. I've created a function, with the sequence. This function return de value of the sequence. I want taht the attribute takes the value of the sequenece dinamically.
    I've tried it, creating the type attribute like PLSQL, and calling the function from the attribute, but it doesn't work.
    How can I return the sequence value to my attribute?
    Thanks.

  • Error PLS-00306 during calling PL/SQL function from Java

    Hi all,
    I am facing a problem during call of oracle PL/SQL function from java using CallableStatement.
    I receive following error message.
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    As per above error EXPORT_HIST_ALARMS_FUNC in oracle has this signature.
    CREATE OR REPLACE FUNCTION EXPORT_HIST_ALARMS_FUNC(startDateTime VARCHAR2, endDateTime VARCHAR2, meType VARCHAR2) RETURN VARCHAR2 IS
    END EXPORT_HIST_ALARMS_FUNC;
    Above function I have called following way in java.
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(2,startDateTime);
    cStatement.setString(3,endDateTime);
    cStatement.setString(4,meType);
    cStatement.execute();
    msg = cStatement.getString(1);
    Actually above function requires three input parameters and one return parameter.
    During execution of above java code it throws SQLException and shows PLS-00306: wrong number or types of arguments in call to 'EXPORT_HIST_ALARMS_FUNC' error.
    I have run this function directly from oracle with three parameters and run successfully and finally it returns string.
    But I am unable to figure out why it doesn't run from above java code.
    Please help regarding this.
    Thanks.
    Regards,
    Shardul Banker

    Try this:
    String sql = "begin ?:= EXPORT_HIST_ALARMS_FUNC(?, ?, ?); end;" ;
    CallableStatement cStatement = null;
    cStatement = connection.prepareCall(sql);
    cStatement.registerOutParameter(1,Types.VARCHAR);
    cStatement.setString(1,startDateTime);
    cStatement.setString(2,endDateTime);
    cStatement.setString(3,meType);
    cStatement.execute();
    msg = cStatement.getString(1);Regards,
    Martijn Teigeler
    Edited by: mTeigeler on Oct 13, 2007 10:22 AM

  • How can i call forpro prg file from java

    Hai friends,
    I have a doubt,clear it.
    how can i call forpro prg file from java file
    by,
    N.Vijay

    Thanks to your reply,
    I have some print statements in my foxpro program file.
    Then i like to invoke that foxpro file from my java file
    This want i want..,
    by,
    N.Vijay

  • How to call a php function from java...

    helllo fellow java developers!
    Im trying to figure out how I can call a php function from my java code.
    I know it sounds a bit unintiutive, seeing how java is a rich programming language, BUT java simply cannot do the task that the php script can do. It simply acts differently.
    So I am trying to call a php function, that returns a string object, and capture that string object....
    is this possible?
    something like....
    String strMyString = phpFunction( strVariable )
    ???????/ any ideaS?

    idea #1 - come up with a better plan that doesn't involve invoking php from java.
    Give one example of something php can do that java can't.
    idea #2 - forget java, and just write it in php.
    Involving multiple frameworks/languages/runtime environments is a recipe for an overcomplicated solution that will be impossible to maintain.
    I'd say keep it simple and stupid, and stick with one language.
    If you're still hooked on the idea, maybe try [this link|http://www.infoq.com/news/2007/10/php-java-stack]

  • How can i call a c++ function through java

    Hi,
    dose anyone knows how to call a C++ function in java?
    Thanks.

    see JNI...
    basically declare a native method in your java class, then run javah on the class thus generating a *.h file. Then implement the c/c++ function. Compile the c/c++ part as a shared library, and make sure its accessible from your LD_LIBRARY_PATH env variable.
    Go through the steps in the JNI docs, and things shoulde be fine... hopefully ;)

  • Executing DLLs from Java using JNI vs Runtime.exec()

    I am trying to understand the best way to execute a dll using java. The dll I am testing with takes a few input parameter. If I use JNI with System.loadLibrary("dll"); what do I need to do to pass the arguements in as well? Can I just add the arguements in the java code like private int xyz = "value"; and expect that the dll will accept them or is there special definitions I have to set up in the dll to make it work?
    Alternatively I was looking at using Runtime to execute the dll by using Runtime.exec("dll param1 param2",env,filePath); Does anyone know if there are drawback to doing it this way vs. using JNI or is this just as efficient? Any help would be appreciated.

    You seem to be confused...
    "execute a dll using java"
    Unless I'm mistaken, a dll is not executable. A dll is a library of code. This code has (hopefully) some well-defined entry points (declared in a header file somewhere) which you must call in a C/C++ file. The arguments you pass to the dll will come from java through JNI.
    As far as your understanding of this entire process, it is obviously confused beyond the scope of a simple reply. I recommend you read the examples and ALL of the documentation available here:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    When you get the/an example running (or just set up to run) then post your code and comments here for more help.
    Ian

  • How can I call a hsqldb procedure from Java

    Hello,
    I am trying to call from Java a stored procedure but I keep having exceptions!!!
    In addition, I have no idea how I can get the result of the procedure !!!!
    I have spent the whole day in Internet.... no luck!!
    ===============================================
    I[b] java.lang.Exception: +updatejava.sql.SQLException: Unexpected token: # in statement [ call MODIFY_FIELD_SEPARATOR(#) ]
         at util.UtilBean.test_upd(UtilBean.java:369)
    ===============================================
    The following procedures have been created and tested withing the database and there work.
    - public static String manage_field_separator(String ifs)
    -public static String manage_refresh_interval(int val)
    The alias have been created:
    CREATE ALIAS MODIFY_FIELD_SEPARATOR FOR "com.lucent.util.StoredProcedures.manage_field_separator";
    CREATE ALIAS MODIFY_REFRESH_INTERVAL FOR "com.lucent.util.StoredProcedures.manage_frefresh_interval
    My file.java contains the flollowing:
    public String test_upd(String tableName, String paramValue)
                                         throws Exception
       String res="0";
       Connection conn=null;
       CallableStatement cs= null;
        try
          conn=DBConnection.DBConnect();
          String p="MODIFY_"+tableName.toUpperCase()+"("+paramValue+")";
          cs=conn.prepareCall( "{call "+p+"}");
         cs.execute();
           // Suppose to get the result res  of the function!!!!
        catch (SQLException e)
         exceptionMessage="+update"+e.toString();
         System.out.println("exceptionMessage="+exceptionMessage);
         throw new Exception(exceptionMessage);
        finally
          Statement stmt=null;
          DBConnection.closeConnection(conn,stmt);
        return res;
      }Obviously I am doing something wrong ..... but I don't know what!!!
    Could you help me please?
    THanks a lot!

    Thanks for your quick response.
    I need to construct the name of the procedure on the fly because I don't know the name of the table I need to modify until excecution time.
    I have modified the code the following way but it still does not work!!!
    I still get the exception:
    java.lang.Exception: +updatejava.sql.SQLException: Unexpected token CALL, requires SELECT in statement [(call MODIFY_FIELD_SEPARATOR(?)}]
         at util.UtilBean.test_upd(UtilBean.java:380)
    public String test_upd(String tableName, String paramValue)
                                         throws Exception
       String res="0";
       Connection conn=null;
       CallableStatement cs= null;
        try
          conn=DBConnection.DBConnect();
          cs=conn.prepareCall( "(call MODIFY_"+tableName.toUpperCase()+"(?)}");
         cs.setString( 1, paramValue);
         cs.execute();
           // Suppose to get the result res  of the function!!!!
        catch (SQLException e)
         exceptionMessage="+update"+e.toString();
         System.out.println("exceptionMessage="+exceptionMessage);
         throw new Exception(exceptionMessage);
        finally
          Statement stmt=null;
          DBConnection.closeConnection(conn,stmt);
        return res;
      }

  • Call Excel Macros function from Java

    Hi All,
    can u guide me How to call excel macros from java.
    The thing is first I have to enable macros and then call the macors function.
    Is this possible to call from Java. If yes guide me.
    Thanks in Advance

    Seems like something you'd have to do through COM.
    http://sourceforge.net/projects/jacob-project/
    HOW you do that is something you'll really have to figure out yourself, its not a Java question.

  • How can I call a Jscript function from XML, which is written seperatly outside the xml file

    Dear All,
    I have made a SharePoint ribbon button which should display an alert message with SharePoint custom list
    ID information. But it has problem for calling the Jscript methods, It may be a XML tag mistake!!! Unable to
    find the error in code line!!!, can somebody please tell me this error by referring my code snippet????
    It is a farm SharePoint solution I have kept the Jscript file in mapped folder named "Layouts"
    It  is showing the error as : JavaScript runtime error: The value of the property 'myFunction' is null or undefined, not a Function object
    That means, as I understand the control is not moving or not calling the function from JScript file....why it
    is so...not able to debug JScript or xml using Visual Studio that makes my effort tedious!!!
    Code:
    Elements.xml
    <CommandUIHandlers>
    <CommandUIHandler Command="ShowAlert" CommandAction="javascript:retrieveListItems()" EnabledScript="return true;"/>
    </CommandUIHandlers>
    <CustomAction Id="Ribbon.Library.Actions.Scripts" Location ="ScriptLink" ScriptSrc="/_layouts/RibAlert.js"/>
    </Elements>
    RibAlert.js
    <script>
    var siteUrl = http://A5-1224';
    function retrieveListItems()
    var clientContext = new SP.ClientContext(siteUrl);
    var oList = clientContext.get_web().get_lists().getByTitle('Measurements'); //getByTitle('Custom List');
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
    '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    </script>

    Hi,
    I suggest you write an alert() in your function to check whether it can be executed first.
    If alert() is ok, then it would be an issue of the code with Client Object Model, you can take a look at the link below about How to retrieve List Items Using JavaScript:
    http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
    If alert() can’t be executed, then please check whether the steps of created ribbon button is correct.
    The links below about how to add a custom button to the ribbon:
    http://aarebrot.net/blog/2010/09/adding-a-custom-button-to-the-ribbon-using-a-feature-in-sharepoint-2010/
    http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-create-custom-button-in-sharepoint-2010-ribbon-user-interface/
    https://pholpar.wordpress.com/tag/custom-actions/
    What’s more, there seems no query succeeded handle function in your code, please take a look at the link provided above for a reference.
    Thanks
    Patrick Liang
    TechNet Community Support

  • Calling a javascript function from java code and getting tha value in Java

    Hi,
    I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
    for example the code snippet is:
    if(true){
    // I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
    <html>
    <head>
    <script type="text/javascript">
    function confirmRemove() {
         var answer = confirm("Are you sure you want to Delete?")
    </script>
    </head>
    <body>
    <form>...

    Hi,
    Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
    There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
    look at this article which shows how (based on JSObject)
    [http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
    Regards,
    Alan Meio
    London,UK

  • Can we call DMS Attachment Function from ECC to SRM

    Hello All,
    We have the below requirement.
       a)  User Create the RFx(SRM) from PR(ECC) vai CPPR functionality.Now during creation we need to copy the DIR Links of  PR to RFx .
      b) In SRM RFx ,at item level we need to place a button called "DIR" ,when user click on the button , we need to bring the   DMS Attachment POP UP from ECC to SRM , where user can add new DIR or Delete the DIR.
               Can we do the requirement  "b" ? , is there way we can call the "DMS Attachment Function"  from SRM? . Kindly share your thoughts.
    Thanks
    Channa.
    DMS Attachment Function"

    Dear Channa,
    due to your screenshot I saw that you are still working with old object link dynpros.
    To grant that allways the currenct screens and authorizations were called please maintain also the value "1" into the "Authorization" column. For further informations on this maintainance please see the attached note 1066915. It's important that you not enter the mentioned screen number wihtout the leading "1" as this number is added automatically by the system (e.g. object MARA 1201 maintain like MARA 201). You can do this in customizing under:
    Transaction SPRO
    > Cross-Application-Component
         > Document Management
              > Control Data
                  > Define screen for object links
    If you need the dynpro number or object you will find all standard SAP objects and their screen number in function module CV130 (Screens) by transaction SE80. Please maintain all necessary SAP objects.
    Best regards,
    Christoph

  • Can we call a javascript function from backing bean class?

    I have a requirement. In a multiselect table, when users selects some rows and clicks a button. Depending upon some condition, an alert box should appear with 2 buttons 'Yes' and 'No'. On clicking yes, certain field values in the selected rows of table should change. On clicking no, the alert box should close. As far as i know alert box can be done only in JS.
    Please help me, if a javascript function can be called in backing bean method or suggest some way where alert boxes can appear through ADF.

    I need to go back to the backing bean as i need to iterate through each selected row of the table in a method( method written for command button) and then if atleast one of the selected rows has job field='Manager', then an alert box needs to be displayed. If none of the rows have job field as 'manager', alert box should not be displayed.
    If I write the function for onclick, i cannot iterate through the selected rows of the table in JS function.
    Please suggest a way to do this.

  • Is it possible to call a C-function from Java?

    Hey!
    I have some extern variables written in C-language, can i get them into a java-file using java? How to do this otherwise?
    Can i use Native interface java? Or is that only the opposite way?
    Thanks
    Mikael

    Hey!
    I have some extern variables written in C-language,
    can i get them into a java-file using java? How to
    do this otherwise?No.
    >
    Can i use Native interface java? Or is that only the
    opposite way?If you wrap that C in C++ and compile it into a .dll or .so you can use JNI.
    %

  • To read a DLL from java using JNI

    Hi,
    I had some DLL files (VB 5.0) which are providing interfaces. Is there any chance of accessing that using java (JNI). Also is there any De - Compiler available so that I can get the source code of the DLL file.
    Regards,
    Hari.

    Hola Hari
    To make a dll loadable through JNI, the interface
    inside
    the dll must be implemented the JNI way. Also a COM
    interface does not help.
    I would reccomend a certain product to automatise the
    JNI interfacing process, but that would
    require that you have the sourcecode of the dll
    available.
    But one thing you can do is to write a wrapper that
    contains the dll classes and is implemented the JNI
    way.
    More precisely you write an interface wrapper in c/c++
    that matches the methods of the dll and does use JNI
    methods. Now inside that c++ wrapper you load the dll
    and forward the calls from java to c++ vice versa.
    Download the demo version of CENTRO.java here:
    www.ablon.de
    Bye, nilsHi Nils,
    Thank you for your suggestion. Im new to JNI.
    That dll's are in Visual Basic. I don't have the source code of the dll file. I got the interfaces available in the dll file from a Visual Basic program which make use of the dll file(which we are talking about). As I know only the method signatures in the interfaces(dll file), I request you to kindly provide me some help to wrap it in C/C++ program.
    Thanks in advance.
    Regards,
    Hari.

Maybe you are looking for