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 ;)

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.

  • How can i send and recieve mail through java

    HI All,
    plz let me know how can i send and receive mail through java.
    Regards:
    sachin kakkar
    http://www.datamansoftwares.com

    Using java mail API..
    try to search the forum for java mail... you find many question and answer.
    use the left search textfield

  • 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 the DLL functions through Java

    Hello,
    I have already got a VC++ generated DLL. It has serveral functionalities. I need to call those functions from my Java Application. Now i know that it can be possible only through writing Java JNI Interfaces.
    Everywhere i only see they give an example where in they tell to create an DLL. Now how do i will call if an DLL is ready and exists.
    If anyone can give an example then it will be very helpful to me. Please mail me at [email protected] .
    Thank you
    vvpatro

    You can't call functions in an arbitary DLL form Java. You need to use JNI to produce a 'wrapper' DLL that maps Java methods to the methods in the target DLL. The purpose of the wrapper is to allow type conversion between Java types and C/C++ types. The complexity of this task depends largely on the types used in th target DLL. If the targer DLL uses only primitive types such as char, byte, int, long, string, the translation is simple and the wrapper DLL will be 'thin'. If however, the target DLL passes arrays and objects, or employs callbacks, these more work to do, and the wrapper will be correspondingly 'thicker'.
    Hope this helps.

  • How can I call a public function in one component from another component?

    I have two components: Form and Confirmation.  Form is a Canvas and Confirmation is a TitleWindow.
    Form contains several controls and a submit button.  Confirmation contains an OK button.  When the user clicks the submit button, the Confirmation appears over the Form (Form is blurred).  When the user clicks the OK button on the Confirmation, I want to run a function on Form to set some default values in the controls.
    How can I address the function in the Form component from the Confirmation component so I can fire the function?
    Thanks!

    Here is the source
    CustomForm.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:Script>
    <![CDATA[
    public function callBack(): void {
    lblStatus.text = "Success";
    ]]>
    </mx:Script>
    <mx:Label id="lblStatus"/>
    <mx:Form x="50" y="50" verticalGap="15">
            <mx:FormHeading label="Send us comments" />
            <mx:FormItem label="Full Name:">
                <mx:TextInput id="fullName" />
            </mx:FormItem>
            <mx:FormItem label="Email:">
                <mx:TextInput id="email" />
            </mx:FormItem>
            <mx:FormItem label="Comments:">
                <mx:TextArea id="comments" />
            </mx:FormItem>
            <mx:FormItem>
                <mx:Button id="submit"
                    label="Submit" />
            </mx:FormItem>
         </mx:Form>
    </mx:Canvas>
    CustomTitle.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" width="200" height="80"
    showCloseButton="true" close="closeMe(event)"
    backgroundAlpha="1"
    color="#173553" backgroundColor="#EEEEEE"
    headerColors="#FFFFFF, #CBCCCC"
    borderColor="#666666" borderStyle="solid">
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;
    public var callBack: Function = new Function();
    private function closeMe(event: Event): void {
    PopUpManager.removePopUp(this);
    callBack();
    ]]>
    </mx:Script>
    <mx:HBox width="100%" height="100%" horizontalAlign="center" verticalAlign="bottom">
    <mx:Button id="btnOK" label="OK" click="closeMe(event)" />
    </mx:HBox>
    </mx:TitleWindow>
    TitleWindowSample.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns="*"
    layout="absolute"
    width="100%" height="100%"
    creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;
    private function init(): void {
    customForm.submit.addEventListener(MouseEvent.CLICK, onMouseClick);
    private function onMouseClick(event: MouseEvent): void {
    customForm.lblStatus.text = "";
    var customTitle: CustomTitle = new CustomTitle();
    customTitle.callBack = customForm.callBack;
    PopUpManager.addPopUp(customTitle, this);
    PopUpManager.centerPopUp(customTitle);
    ]]>
    </mx:Script>
    <mx:VBox
    width="100%" height="100%"
    verticalAlign="middle" horizontalAlign="center">
    <CustomForm id="customForm" width="500" height="300">
    </CustomForm>
    </mx:VBox>
    </mx:Application>

  • How can I call a static function in another static function?

    /** = d, as a String, using exactly 5 characters.
    Precondition: 0 <= d <= 999.
    The truncated d will have one of the forms: ddd.d, dd.dd, and d.ddd.
    Examples are: 360.1, 29.50, 4.003, 0.001, and 0.000
    public static String truncateTo5(double d) {
    // To get the desired output, do the following
    // 1. If d < 0.001, set d to 0.
    // This prevents d appearing in scientific notation, e.g. 1.5E-6.
    // 2. Convert d to a string s, in the usual way.
    // s is guaranteed to have a decimal point in it a digit before
    // and after the decimal point.
    // 3. Append zeros to s (if necessary) until s has 5 digits.
    // 4. Return s.
    String s= "" + d;
    if (d < 0.001) {
    d= 0;
    return "0.000";
    if (s.length() > 5) {
    return s.substring(0,5);
    if (s.length() == 3) {
    int l= s.length();
    return s.substring(0, l) + "00";
    if (s.length() == 4) {
    int l= s.length();
    return s.substring(0, l) + "0";
    return s;
    /** = d, but rounded (if necessary) to its first 5 characters.
    PreconditionL 0 <= d <= 360.
    E.g. round 1.3546 to 1.355. round 1.3544 to 1.354.
    E.g. round 21.995 to 22.00. round 21.994 to 21.99.
    E.g. round 130.59 to 130.6. round 130.54 to 120.54.
    public static String roundTo5(double d) {
    // Hint. Rounding to an integer j is usually done by
    // truncating the value j + 0.5.
    // E.g. Change 10.6 to 11.1 and truncate to 11
    // E.g. Change 10.4 to 10.9 and truncate to 10
    // You need to do this sort of thing, but what you add may depend
    // on how big d is.
    What I need to do is call the truncateTo5() in the roundTo5() in order for this to work properly but I dont know how. Can someone help?

    @captfoss: If they're static methods in the same class, you don't even need to do that. You can just call the method unquallified.
    @OP: First off, when you paste code, wrap it in code tags. You can find them between Quote and Help.
    As for your error, you have defined truncateTo5() to take a double as an argument. When you call it, you are not passing it a double and you get that error.

  • How can I call a server function by a button?

    Hello, world...
    I have a problem...
    I need to call a server function by pushing a button. I put the condition on the label...
    This is my script:
    writeBtn1.addEventListener (MouseEvent.CLICK,writeFile1);
    private function writeFile1 (e:MouseEvent=null):void
                 checkBtn = (writeBtn1.label == "Conferma" && textInput1.text != "" );  //my condition...
                 if (checkBtn)
                     nc.call ("WriteNow",null,textInput1.text+"\n");
                    writeBtn1.label = "Fatto";
    I'd like to call the function on the release of the button...
    Can someone helps me?
    Please...
    Emiliano.

    use:
    writeBtn1.addEventListener (MouseEvent.CLICK,writeFile1);
    writeBtn2.addEventListener (MouseEvent.CLICK,writeFile1);
    writeBtn3.addEventListener (MouseEvent.CLICK,writeFile1);
    private function writeFile1 (e:MouseEvent=null):void
                if(e.currentTarget==writeBtn1){
                 // do whatever
               } else if(e.currentTarget==writeBtn2){
                 // do whateverelese
              } else {
                 // it's writeBtn3

  • 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 ;)

  • RE: How can I call Windows .DLL components in Java

    Hi, there,
    I have a wondows dll component registered on my server. I want to call this componet in my Java application(Servlet). Could you tell me the syntex or is this possible to do in this way?
    TIA,
    Xin

    Thank you for your reply. Did you suggest using JNI? Since this DLL is a comercial component and we can not recompile or modify it, I donot know how to use it. Could you give me some more detail ?
    Thank you,
    Xin
    You can use either of the load or loadLibrary methods
    in java.lang.System. The library has to be loaded at
    the very beginning of loading of the class , if the
    class were to access any native method in the
    library.
    Hence, it shoud be in a static block.
    Syntax-
    static {
         try{
              System.load("C:\\x.dll");
         }catch( Exception e ) {
              System.out.println(e);

  • 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

  • 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;
      }

  • How can i call a CGI script from java?

    The subject pretty much says it all. I want to call a perl cgi script so i can read from/write to files on a server. I don't know how to sign applets and this would be the easiest way for me, if someone could please tell me.

    Let me get this clear. Basically what u want to do is to just call a URL, right?
    U can do it by using the following code:
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    public class testhttp
    public static void main(String[] args)
    try
    URL url = new URL ("http://../testcgi.cfm");
    HttpURLConnection cxn =
    (HttpURLConnection)url.openConnection();
    cxn.setRequestMethod("POST");
    cxn.setUseCaches(false);
    cxn.setDoOutput(true);
    cxn.setDoInput(true);
    ByteArrayOutputStream bytes = new
    ByteArrayOutputStream(400);
    PrintWriter writer = new PrintWriter (bytes,true);
    writer.print("application=map&release=1&items=prog1");
    writer.flush();
    cxn.setRequestProperty("Content-
    Length",String.valueOf(bytes.size()));
    cxn.setRequestProperty("Content-
    Type","application/x-www-form-urlencoded");
    bytes.writeTo(cxn.getOutputStream());
    System.out.println(bytes);
    String currentLine;
    BufferedReader in = new BufferedReader (new
    InputStreamReader(cxn.getInputStream(),"8859_1"));
    while((currentLine = in.readLine()) != null) {
    System.out.println(currentLine); }
    catch(Exception e) { e.printStackTrace(); }
    There is also a library called HTTP client which can be found at:
    http://www.innovation.ch/java/HTTPClient/index.html
    It's very simple to use and the documentation is all there, but their web server seems to be down right now.
    Anyway, hope my post helps.

  • How can we call actionscript functions from js

    hi
    how can we call Action script function from js file . i
    tried ExternalInterface. add Callback() .but it throws an error .is
    there any other chance to call action script method .thnx in
    advance

    angadala,
    some people have found it is good to include the full
    qualification path, ie
    if (flash.external.ExternalInterface.available)
    flash.external.ExternalInterface.addCallback("ext_method_name",int_method_name);
    } // if (flash.external.ExternalInterface.available)
    There are also browser differences which affect how you find
    the Flex application object which are documented at
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=passingarguments_5.html
    Richard

  • How can i call the Buttons which made in flash

    Sir
    i design some Flash buttons but it is save as .swf extension
    if i save as jpg or gif then animation not working as well as
    effects.
    sir
    how can i call the flash buttons in java plz guide me
    JButton mybutton=new JButton(how can i pass swf extension button);

    of course, anything's possible, but to do this means first getting a bridge from flash to javascript or com or something, and then a bridge from javascript to Java. So in short,
    It's not possible.

Maybe you are looking for

  • Values not saved in "Global Authentication Setup" page

    Hi, I searched a bit in this forum but I couldn't find a related topic. So here is my problem. We are trying to deploy a small NAC lab environment. We use NAC Appliance v4.1. Now the problem is, that I like to set the values for PEAP and EAP-TLS in t

  • CSV download

    I have one filed Notes on which i have a tooltip.for Notes filed have two field one is for displaying purpose which is truncated and another one is field containing whole text use for CSV download. things work first time fine if the use request=CSV f

  • Chinese language support

    Hi, I'm a new Mac user. I'm having trouble reading simplified and traditional Chinese characters using both Safari and Firefox. I also am not sure the overall Chinese input system on the Mac. I've enabled it and can change into that "mode" to write p

  • Prepaid Coverage in Alaska?

    I have a prepaid plan that I had back on Alltel before Verizon bought it.  It's a Samsung Razr SCH-R500 model.  I've been using Straight Talk  for a few years now.  I haven't used this phone in ages, but I still keep adding minutes (through Verizon p

  • Datpump Export,Import across lower and higher versions

    Versions involved : 10.2.0.4, 11.2.0.3 Operating System  : AIX 6.1 +++++++++++++++++++++++++++++++++Lets say I export a schema in a 11.2 Database using 11.2 expdp . Can I import the above dump (11.2) to a 10.2 Database using 10.2 impdp ?