Invoke Java method from C++

hello, I hope you can help me.
In the moment I am trying to use Global Hotkeys.
I am able to register global Hotkeys from Java in C++. My problem: I can't invoke an other java method as result of pressing my hotkey.
void OnHotKey(void *)
     printf("invoke my java method");
so I want to do a backcall to java in a c++ method. At Beginning Java registers my global Hotkeys in an c++ native method.

(My JNI is rusty, and the tutorial is gone),
Something like (Pusdo code, see JNI Spec: Accessing Fields and Methods ):
        JNIEnv * g_env, jobject g_obj;
     void OnHotKey(void *)
          // cut from the example posted above
          jclass cls;
          jmethodID mid;
          cls = (*env)->FindClass(env,"my.Class");
          if( cls == NULL ) {
                    return;
          mid=(*env)->GetMethodID(env, cls, "onHotKey", "()V");
          (*env)->CallVoidMethod( obj, mid );
     CHotkeyHandler hk;
     JNIEXPORT void JNICALL Java_gui_Gui_activateGlobalHotkeys
     (JNIEnv * env, jobject obj) {
          int err, id;
             hk.RemoveHandler(id = 0);
          hk.InsertHandler(MOD_CONTROL | MOD_ALT, 'A', OnHotKey, id);
          // We need this in OnHotKey
          g_env = env;
          g_obj = obj;
          err = hk.Start("calc.exe");
          if (err != CHotkeyHandler::hkheOk)
               printf("Error %d on Start()\n", err);
     JNIEXPORT void JNICALL Java_gui_Gui_deactivateGlobalHotkeys
     (JNIEnv * env, jobject obj) {
          int err = hk.Stop();
}

Similar Messages

  • Invoking java methods from C/C++ on the machine with different JREs

    I implemented Windows NT Service instantiating JVM and invoking several java methods. Everything works but I have an issue with running the service on the machine where multiple different versions of JRE have been installed. The service is calling java methods that require JRE 1.3 or later so I wrote the code that is setting system PATH from within the service based on the configuration stored in the external file. The problem is that the service requires jvm.dll to be in the PATH prior lunching it since this library is instantiated through the implicit linking. When I put jvm.dll in the same path as the service binary I can lunch it but JNI_CreateJavaVM fails and returns -1. This happens even if JRE 1.3 is in the system PATH prior lunching the service.
    Everything works if the system PATH contains references to JRE 1.3 and jvm.dll is removed from the service's directory.
    I am looking for an advice on what is the proper way to deal with invoking java methods from the C/C++ executable in the environment with different versions of JRE.
    Thanks, Kris.

    Here's a way I have done what you are asking about:
    What you want to do is make all of your linking happen at runtime, rather than at compile time. This way, you can edit the PATH variable before the jvm.dll gets loaded.
    Following is some code that I used to handle a dll of my own in this manner. You can decide if you want to write a "wrapper" dll, or if you find it simpler to approach the jvm.dll in this way.
    // Define pointer type for DLL entry point.
         typedef void JREPDLL_API (*EXECUTEREQUEST)(char*, Arguments&);
    // Set up path, load dll, and pass everything off to it.
    HINSTANCE javaServer = javaServer = LoadLibrary("jrepdll.dll");
    if (javaServer != NULL) {
    EXECUTEREQUEST executeRequest = (EXECUTEREQUEST)GetProcAddress(javaServer, "ExecuteRequest");
    if (executeRequest != NULL) {
    if (argc == 1)
         // Execute the request.
         executeRequest("-run", args);
    else
         // Execute the request.
         executeRequest("-console", args);
    Here's some code for how to edit the PATH:
              // Edit the PATH environment variable so that we use our private java.
    char *appendPt;
    char *newPath;
    char *path;
              char tmp[_MAX_PATH];
              // Get the current PATH variable setting.
    path = getenv("PATH");
              // Allocate space for an edited path setting.
              if (path != NULL)
                   newPath = (char*)malloc((_MAX_PATH * 2) + strlen(path));
              else
                   newPath = (char*)malloc((_MAX_PATH * 2));
              // Get upper part of path to desired directories.
              strcpy(tmp, filepath);
              appendPt = strstr(tmp, "dbin\\jreplicator");
              appendPt[0] = '\0';
    sprintf(newPath, "PATH=%sjava\\jre1.2.2\\bin;%sjava\\jre1.2.2\\bin\\classic", tmp, tmp);
    // Append the value of the existing PATH environment variable.
    // If there is anything, append it.
    if (path != NULL) {
         strcat(newPath, ";");
         strncat(newPath, path, (sizeof(newPath) - strlen(newPath) - 2));
    // Set new PATH value.
    _putenv(newPath);
              free(newPath);

  • Invoking Java Methods from outside ODI

    Is there a good blog on how to do this, I assume a procedure is the best way?

    Bos that makes sense and seems to work, I put this into my text variable:
    SELECT
    CAST(COLLECT(to_char(trade_id)) AS oditmp.t_varchar_tab) AS trade_id
    FROM oditmp.trade_ids
    Validated and returned this when I checked the history :
    Date Value Context
    2011-07-01 08:33:01.0     oracle.sql.ARRAY@294d7bc     DEVELOPMENT
    I assume the values are loaded in here and I can modify my Java Code as below?
    In SQL Developer the same query returns:
    ODITMP.T_VARCHAR_TAB(1,2,3,4,5,6)
    -- Change to Java:
    // Declare variables
    import jar_jcmf;
    trade_ids String;
    String [] str_arr;
    jar_jcmf t = new jar_jcmf();
    int n;
    // Load string array of table values, NOT SURE ABOUT THIS STEP
    trade_ids = #PRJCT.TRADE_IDS;
    // Split String
    str_arr = trade_ids.split(",");
    // Loop over array and execute GetTrade method from JCMF Class
    for (String rec : str_arr) {
    n = Integer.parseInt(rec)
    t.getTrade(n);
    };

  • How to invoke Java method from C++

    Hi
    My requirement is In C++ we are having three different structures, like
    struct one{
    int accontno;
    char * accountholdername;
    long balance;
    struct two{
    int startdate;
    int enddate;
    struct three{
    char* userid;
    char* userpassword;
    from c++ how to pass these structures, these structures I have to read in Java class, and in java how receive these structures.
    And the sample methods will be like: getCarsData(Input, output, Error);
    How do i call the method in JNI, if it is static int method we can call like
    getStaticIntMethodID(), instead of int if i have to pass the above mentioned structures how do i do? Should i create an object array in JNI for accessing these three structures?
    Suggestions/Samples welcome
    Thanks,

    Why did you start another thread for this?
    I was answering you in the [url http://forum.java.sun.com/thread.jspa?threadID=712137&messageID=4119725#4119725]old thread and you didn't even bother to answer back my (basic) questions.
    I told you to use the code tags when pasting code. Got ignored. I also gave you a starting example on how to achieve your goal. Flushed.
    Oh well, I'm getting used to it.
    Again.
    Before starting, allways keep near you the [url http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html]JNI reference. All the JNI functions are documented in it.
    First you need to create custom Java classes that will match the C++ stucts (remember?).
    There is no magic wand in JNI that will transform the C++ structs into the custom Java classes and vice versa.
    You'll have to code it by hand, one field at a time. It's a pain.
    So for the one, two, three C++ structs (why not posting some real names instead of this crap?),
    there will be JOne, JTwo and JThree Java classes.
    There is also that other Java class already existing with getCarsData() static method that will fetch the data.
    And finally the DLL function wich will call this Java static method, doing the bridge between the C++ structs and the custom Java classes, finally return the data.
    Due to the lack of explanation from your posts, I will say that the getCarsData() static method receives a parameter of type JOne
    and returns an array of JTwo objects.
    So the get_cars_data() DLL function receives a parameter which is a struct one and
    returns a pointer to an array of struct two elements.
    // C++ structs
    struct one {
        int accontno;
        char * accountholdername;
        long balance;
    struct two {
        int startdate;
        int enddate;
    struct three {
        char * userid;
        char * userpassword;
    // custom Java classes
    class JOne {
        int accontno;
        String accountholdername;
        int balance;
    class JTwo {
        int startdate;
        int enddate;
    class JThree {
        String userid;
        String userpassword;
    // Java class with static method that gets the data
    class DataFetcher {
        static JTwo[] getCarsData(JOne one) {
    // DLL function
    // struct 'one' parameter is already filled with values.
    // Returns an array of 'two' C++ struct obtained from a Java static method
    two * get_cars_data(one o) {
        JNIEnv * env;
        /** not show here is the code to either
            create the JVM or
            attach it to the current thread **/
        // get the data from 'one' C++ struct and put it in a new instance of JOne Java class
        jclass oneCls = env->FindClass("JOne");
        jmethodID oneCtorID = env->GetMethodID(oneCls, "<init>", "()V");
        jfieldID accontnoID = env->GetFieldID(oneCls, "accontno", "I");
        jfieldID accountholdernameID = env->GetFieldID(oneCls, "accountholdername", "Ljava/lang/String;");
        jfieldID balanceID = env->GetFieldID(oneCls, "balance", "I");
        jobject oneObj = env->NewObject(oneCls, oneCtorID);
        env->SetIntField(oneObj, accontnoID, o.accontno);
        env->SetObjectField(oneObj, accountholdernameID, env->NewStringUTF((const char *)o.accountholdername));
        env->SetIntField(oneObj, balanceID, o.balanceo);
        // call the Java static method
        jclass dfCls = env->FindClass("DataFetcher");
        jmethodID getCarsDataID = env->GetStaticMethodID(dfCls, "getCarsData", "(LJOne;)[LJTwo;");
        jobjectarray twoArray = (jobjectarray)env->CallStaticObjectMethod(dfCls, getCarsDataID, oneObj);
        // create the 'two' C++ struct array from the Java array of JTwo objects
        jclass twoCls = env->FindClass("JTwo");
        jfieldID startdateID = env->GetFieldID(twoCls, "startdate", "I");
        jfieldID enddateID = env->GetFieldID(twoCls, "enddate", "I");
        jint len = env->GetArrayLength(twoArray);
        two * pt = new two[len];
        for (int i = 0; i < len; i++) {
            jobject twoObj = env->GetObjectArrayElement(twoArray, i);
            pt.startdate = env->GetIntField(twoObj, startdateID);
    pt[i].enddate = env->GetIntField(twoObj, enddateID);
    // return the resulting 'two' C++ struct array
    return pt;
    Regards

  • Call Java Method From C#

    I have a complete Java Classes solution working perfectly and i would like to "re-use" it from my new main C# program. Actually, i don't know which process could authorize to invoke Java method from C# method.
    Can anybody help me ?
    Thanks in advance for your assistance.

    If you want a very heavy and inefficient solution you can try this:
    - Make your java classes "web services" - it usually requires setting up a web container like Tomcat
    - Call the web services in your C# program.
    Sometimes my solution could work (for instance, if your Java classes can't be rewritten in C# in a short time, and if they are infrequently called, and if they do a lot of work inside, and if you already has a web container properly set up in your environment).

  • Invoke beanshell methods from java

    Hello
    I'm learning beanshell and using it to write scripts that are ran in JDK 6.
    My question is how to invok beanshell methods from java source codes.
    My codes is:
    import javax.script.*;
    public class InvokeFunctions {
    public static void main (String[] args)throws ScriptException, NoSuchMethodException
    ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine bshEngine = sem.getEngineByName("beanshell");
    String script = "public void sayHello()"+"{print (\"sayHello() is a method in bsh script\");}";
    bshEngine.eval(script);
    Invocable inbshEngine = (Invocable)bshEngine;
    inbshEngine.invokeFunction("sayHello");
    I defined a method "sayHello()" using beanshell, but i just can't invoke it in Java.
    I got an error msg said:
    Exception in thread "main" java.lang.IllegalAccessError: tried to access method bsh.NameSpace.getThis(Lbsh/Interpreter;)Lbsh/This; from class bsh.engine.BshScriptEngine
    Any one has any idea about it?
    Thanks

    Look at the Javadoc documentation of IllegalAccessError. It says:
    Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.
    Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.
    Maybe recompiling all your sources (make sure you delete all existing *.class files) will help?

  • Problems invoking a method from a web service

    Am using netbeans 6.1 and my problem is when i invoke a method from a web service that has a custom class as a return type.
    When I debug the client that consumes my web service, It get Stack in this line:
    com.webservice.WebServiceInfoBean result = port.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL);
    i don't get any error on the console.
        static public void function1() {
            try { // Call Web Service Operation
                com.webservice.WebServiceMonitorService service = new com.webservice.WebServiceMonitorService();
                com.webservice.WebServiceMonitor port = service.getWebServiceMonitorPort();
                // TODO initialize WS operation arguments here
                java.lang.String nameSpace = "NameSpaceHere";
                java.lang.String serviceName = "WebServicePrueba";
                java.lang.String portName = "Soap";
                java.lang.String wsdlURL = "http://localhost/Prueba/WebServicePrueba.asmx?wsdl";
                // TODO process result here
                com.webservice.WebServiceInfoBean result = port.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL); // <--- here it stack
                System.out.println("getWebServiceInfo");
                Iterator i = result.getMethods().iterator();
                while (i.hasNext()) {
                    MethodBean method = (MethodBean) i.next();
                    System.out.print("Nombre: " + method.getname());
                    System.out.print(" Returns: " + method.getreturnType());
                    Iterator j = method.getparameters().iterator();
                    while (j.hasNext()) {
                        ParameterBean parameter = (ParameterBean) j.next();
                        System.out.print(" ParameterName: " + parameter.getname());
                        System.out.print(" ParameterType: " + parameter.gettype());
                    System.out.print("\n");
                    System.out.print(method.getfirma());
                    System.out.print("\n");
                    System.out.print("\n");
            } catch (Exception ex) {
                ex.printStackTrace();
        }Web Service side
         * Web service operation
        @WebMethod(operationName = "getWebServiceInfo")
        public WebServiceInfoBean getWebServiceInfo(@WebParam(name = "nameSpace")
        String nameSpace, @WebParam(name = "portName")
        String portName, @WebParam(name = "serviceName")
        String serviceName, @WebParam(name = "wsdlURL")
        String wsdlURL) throws Throwable {
            //TODO write your implementation code here:
            webservicemonitor instance = new webservicemonitor();
            return instance.getWebServiceInfo(nameSpace, serviceName, portName, wsdlURL);
        }I have tested my internal code from the web service side and everything works fine. The problem occurs when i invoke it from a client side. probably I did not made the right serialization form my class WebServiceInfoBean? or am missing something. here it is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package com.beans;
    import java.util.ArrayList;
    * @author Tequila_Burp
    public class WebServiceInfoBean implements java.io.Serializable {
         * Holds value of property wsdlURL.
        private String wsdlURL;
         * Getter for property wsdlURL.
         * @return Value of property wsdlURL.
        public String getwsdlURL() {
            return this.wsdlURL;
         * Setter for property wsdlURL.
         * @param wsdlURL New value of property wsdlURL.
        public void setwsdlURL(String wsdlURL) {
            this.wsdlURL = wsdlURL;
         * Holds value of property namespace.
        private String namespace;
         * Getter for property namespace.
         * @return Value of property namespace.
        public String getnamespace() {
            return this.namespace;
         * Setter for property namespace.
         * @param namespace New value of property namespace.
        public void setnamespace(String namespace) {
            this.namespace = namespace;
         * Holds value of property serviceName.
        private String serviceName;
         * Getter for property serviceName.
         * @return Value of property serviceName.
        public String getserviceName() {
            return this.serviceName;
         * Setter for property serviceName.
         * @param serviceName New value of property serviceName.
        public void setserviceName(String serviceName) {
            this.serviceName = serviceName;
         * Holds value of property wsdlURL.
        private String portName;
         * Getter for property wsdlURL.
         * @return Value of property wsdlURL.
        public String getportName() {
            return this.portName;
         * Setter for property wsdlURL.
         * @param wsdlURL New value of property wsdlURL.
        public void setportName(String portName) {
            this.portName = portName;
         * Holds value of property methods.
        private ArrayList methods = new ArrayList();
         * Getter for property methods.
         * @return Value of property methods.
        public ArrayList getmethods() {
            return this.methods;
         * Setter for property methods.
         * @param methods New value of property methods.
        public void setmethods(ArrayList methods) {
            this.methods = methods;
        public MethodBean getMethod(int i) {
            return (MethodBean)methods.get(i);
    }by the way, everything has been worked on the same PC.

    Hi Paul,
    This sound familiar, but I cannot at the moment locate a reference to
    the issue. I would encourage you to seek the help of our super support
    team [1].
    Regards,
    Bruce
    [1]
    http://support.bea.com
    [email protected]
    Paul Merrigan wrote:
    >
    I'm trying to invoke a secure 8.1 web service from a 6.1 client application and keep getting rejected with the following message:
    Security Violation: User: '<anonymous>' has insufficient permission to access EJB:
    In the 6.1 client, I've established a WebServiceProxy and set the userName and password to the proper values, but I can't seem to get past the security.
    If there something special I need to do on either the 8.1 securing side or on the 6.1 accessing side to make this work?
    Any help would be GREATLY appreciated.

  • Is it possible to invoke JEB method from thread?

    Hello everybody!
    I have problem creating EJB from the thread. Here is the part of code below:
    public void email() throws Exception {
    class MailThread implements Runnable {
    public MailThread() {
    public void run() {
    try {
    String jndiName "java:comp/env/ejb/PROG/Mail";
    IMailHome mailHome;
    IMail mail;
    InitialContext context = new InitialContext();
    Object objref = context.lookup(jndiName);
    mailHome = (IMailHome) PortableRemoteObject.narrow(objref, IMailHome.class);
    // Exception here:
    // java.rmi.RemoteException: Exception Substitute; nested exception is:
    // java.lang.NullPointerException mail = mailHome.create();
    // business metods
    // mail.method1();
    } catch (Exception e) {
    System.out.println("Exception:" + e);
    MailThread mt = new MailThread();
    Thread thread = new Thread(mt);
    thread.start();
    Exception:
    java.rmi.RemoteException: Exception Substitute; nested exception is:
    java.lang.NullPointerException
    I am not able to create EJB instance from the thread. The same code works well in servlet. Am I doing something wrong?
    May be there are some different approaches to implement some operations asynchronously at EJB level do not using JMS and MDB? J2EE specification prohibits to use threads inside EJB so the only way I see is to create different thread on servlet side and invoke EJB methods from it. But it seems that this doesn't work too. Could anyone help me?
    Thanks in advance,
    Vadim Lotarev

    If the passcode will not work, the only alternative is to restore the phone as new. You cannot change the passcode from the lock screen.

  • Urgent please ! How to invoke java method with diffrent argument types?

    Hi,
    I am new to JNI.
    I had gone through documentation but it is not of much help.
    Can any one help me out how to invoke the below java method,
    // Java class file
    public class JavaClassFile
    public int myJavaMethod(String[] strArray, MyClass[] myClassArray, long time, int[] ids)
    // implementation of method
    return 0;
    // C++ file with Invokation API and invokes the myJavaMethod Java method
    int main()
    jclass cls_str = env->FindClass("java/lang/String");
    jclass cls_MyClass = env->FindClass("MyClass");
    long myLong = 2332323232;
    int intArray[] = {232, 323, 32, 77 };
    jclass cls_JavaClassFile = env->FindClass("JavaClassFile");
    jmethodID mid_myJavaMethod = env->GetMethodID( cls_JavaClassFile, "myJavaMethod", "([Ljava/lang/String;[LMyClass;J[I)I");
    // invoking the java method
    //jint returnValue = env->CallIntMethod( cls_JavaClassFile, mid_myJavaMethod, stringArray, myClassArray, myLong, intArray ); --- (1)
    //jint returnValue = env->CallIntMethodA( cls_JavaClassFile, mid_myJavaMethod, ...........); --- (2)
    //jint returnValue = env->CallIntMethodV( cls_JavaClassFile, mid_myJavaMethod, ...........); --- (3)
    Can any one tell me what is the correct way of invoking the above Java method of (1), (2) and (3) and how ?
    The statement (1) is compilable but throws error at runtime, why ?
    How can I use statements (2) and (3) over here ?
    Thanks for any sort help.
    warm and best regards.

    You are missing some steps.
    When you invoke a java method from C++, the parameters have to be java parameters, no C++ parameters.
    For example, your code appears to me as thogh it is trying to pass a (C++) array of ints into a java method. No can do.
    You have to construct a java in array and fill it in with values.
    Here's a code snippet:
    jintArray intArray = env->NewIntArray(10); // Ten elments
    There are also jni functions for getting and setting array "regions".
    If you are going to really do this stuff, I suggest a resource:
    essential JNI by Rob Gordon
    There is a chapter devoted to arrays and strings.

  • How to invoke Java class from post.POST.jsp

    Hi All,
    I am trying to invoke a simple java method from post.POST.jsp
    I am getting below exception while doing it.
    org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 32 in the jsp file: /apps/mywebsite/components/customFormAction/post.POST.jsp
    The method test() is undefined for the type DatasourceUtil
    29:          
    30:           ///
    31:          com.day.test.datasource.DatasourceUtil dsUtil = new com.day.test.datasource.DatasourceUtilImpl();
    32:          dsUtil.test();
    33:           //dsUtil.validateLogin(request.getParameter("username"), request.getParameter("password"));
    34:          
    35:           ////
    It appears to resolve the class correctly. I could run the code, if I only comment  dsUtil.test();. As soon as I uncomment, it gives above error.
    In the Utill I have a simple void method which will print a simple text. My package structure is as follows.
    any help will be great
    Tx

    1.  In the interface [1] not the implementation[2] have u defined the method test?
    2.  If it is implemented, Change the bundle version in bnd file and make a new build. Then from felix console verify the latest version reflected in the bundles.
    If 2 works & you are going to make lot of frequent changes then give the version as snapshot till it get stable.
    [1]  com.day.test.datasource.DatasourceUtil
    [2]   com.day.test.datasource.DatasourceUtilImpl

  • Invoke Java Library from Flex

    I have Flex running on Tomcat with LCDS. On tomcat there is a JAR that has classes I'd like to use/interact with from Flex. In the simple LCDS examples they demonstrate having a Product.java class and a matching Product.as class, but the java library I am trying to use has many more classes and would take a long time to copy into Actionscript.
    What is the best way to interact with the Java classes (I don't have a web service to use like in the LCDS example).

    I only know we can use JNI to invoke native libraries
    from Java and I have never used JNI to invoke Java
    libraries from native applications (C/C++ programs).
    I am going to look through the tutorial you
    recommended.The last tutorial. I've only fiddled with it, as it was a bitch. If you don't need to use Suns JVM, I recomend using CNI & GCJ [ http://gcc.gnu.org/java/ ], as it is much neater.
    Do you mean JNI is internally implemented by C++s
    Runtime.exec method?Write a small Java application which invokes the lib you want, i.e. say you want to use Strings replaceAll method (simple example I know)
    class Test {
    pubilc static void main( String args[] ) {
      System.out.println( args[0].replaceAll( args[1], args[2] ) ) ;
    }Then use c++ program to run "/path/to/java Test tast a e" .

  • JNI, run Java methodes from C++

    I'm trying to understand the JNI for a while, but can't realy figure out how to run a java methode from a C++ code.
    (I've managed to do the oposit; run a C++ methode from Java, but that is not what I need.)
    The thing is that I have a C++ program wich outputs a jpg picture. And I have a Java program wich is using this picture. (Picture size is from 2 - 4KB)
    My temparary (not good) solution for making the picture available for the java code is to have the C program save it to a file, and then make the java program read the file once in a while.
    What I would like is to have the C++ to call the methode updatePicture(byte[] newJPEG) in my javacode. How do I do this?
    Parts of the C++ sourcecode:
    void CExCameraView::OnTimer(UINT nIDEvent){
    static int timercount=0;
         CExCameraDoc* pDoc = GetDocument();
         timercount+=pDoc->mycameraconfig->RefreshInterval ;
         if (timercount<pDoc->mycameraconfig->LoadOverHeads )
              return;
         else
              timercount=pDoc->mycameraconfig->LoadOverHeads;
         ASSERT_VALID(pDoc);
    //grab one image and save it to a jpeg file
    // here I'd like to call the java updatePicture methode (not save as file)
         pDoc->GrabSaveNext(pDoc->myconfig->cmsTimeOut);
    And parts of the java code:
    class ImageHandler {
    JpegImage jpegImage; // class JpegImage extends Image
    public ImageHandler() {
    jpegImage = new jpegImage();
    setParameters();
    public updatePicture(byte[] newJPEG) {
    setImage(newJPEG);
    // lots of other methods
    Pete
    "If we knew what it was we were doing, it would
    not be called research, would it? [Einstein]"

    Well, you seem to be defining a C program with some imbedded java, or a java program with some native C methods. So which is it?
    o If it is a C program, then you have two things to do (with respect to java):
    - Start a java JVM.
    - During your processing, periodically call into your JVM to process data made available by your C program.
    o If it is a java program, then what you want to do -- I guess - is call a native method to start up an asynchronous (C) process, then have that asynchronous
    process periodically call back into java to process results.
    Overview of JNI (which you need to flesh out with some further study):
    o There is the socalled invocation API, which is used to get java started.
    o There is the definition of java native methods, which are then implemented in a C library (DLL on Windows), which library is loaded up at runtime by the java program, allowing the native methods to be called.
    o There are JNI methods available from C that allow you to look up objects and methods, and invoke those java methods.
    Two references:
    o Essential JNI by Rob Gordon.
    o www.swig.org

  • Java Method from C++

    I am trying to invoke a java method from C++. This java method takes two String parameters as input and returns back a String. This is the Signature I am using and I could not a method ID for this from C++. PLease advise.
    "mid = env->GetStaticMethodID( cls, "doSabreCall", "(Ljava/lang/String;,Ljava/lang/String;)Ljava/lang/String;");"

    First, make sure cls is valid.
    In case you're not sure, once you remove the extra comma you'll be invoking:
    class WhateverClassClsActuallyPointsTo {
      static String doSabreCall( String a, String b );
    }You might want to check out Jace at http://jace.reyelts.com/jace. It's a free, open-source toolkit/library that's designed to handle this exact problem. You can use a tool, proxygen, to automatically generate a C++ proxy for your class, and then call it straight from C++. Your C++ code would look like:
    void callSabre() {
      String result = WhateverClassClsActuallyPointsTo::doSabreCall( "A string here", "And a string here" );
      cout << result << endl;
    }God bless,
    -Toby Reyelts

  • Call Java Method From JavaScript Function

    hi everyone
    i need a help in calling Java method from a javaScript method
    ex:
    function confirmAddRecord() {
    cHours =document.getElementById('frmP:ChargeHours').value;
    cSTime =document.getElementById('frmP:ChargeStartTime').value;
    var answer = confirm("Are you sure you want to add Record?")
    if (answer){
    here i want to call the Java Method that is located in session bean that takes the upper params cHours & cSTime
    else{
    return false;
    i know i can do it as an action button but it is required me to be in that way can any one help plz
    Message was edited by:
    casper77

    That depends on the nature of your parameters. I guess you calculate the params on client and then want to submit them. In this case and if you don't want to use Ajax simple add some <input type="hidden"> elements (of course there correspondend components dependent of your framework) and store the params there. If the javascript isn't invoked by a button click, you can use a button nevertheless. Set visible="false" and call
    document.getElementById('client_id_of_my_hidden_button').click();
    (or maybe doClick() dependent on your framework).

  • Invoke Java library from C/C++

    Hello everyone,
    Are there any approaches to invoke Java libraries from C/C++?
    Thanks in advance,
    George

    I only know we can use JNI to invoke native libraries
    from Java and I have never used JNI to invoke Java
    libraries from native applications (C/C++ programs).
    I am going to look through the tutorial you
    recommended.The last tutorial. I've only fiddled with it, as it was a bitch. If you don't need to use Suns JVM, I recomend using CNI & GCJ [ http://gcc.gnu.org/java/ ], as it is much neater.
    Do you mean JNI is internally implemented by C++s
    Runtime.exec method?Write a small Java application which invokes the lib you want, i.e. say you want to use Strings replaceAll method (simple example I know)
    class Test {
    pubilc static void main( String args[] ) {
      System.out.println( args[0].replaceAll( args[1], args[2] ) ) ;
    }Then use c++ program to run "/path/to/java Test tast a e" .

Maybe you are looking for

  • How to make a gradient on two paths

    Hello, I am fairly new to Illustrator, although have used Photoshop, Fireworks and DW to some degree in the past. In CS4, I am trying to make a country map with different counties or states.  Using the map of the UK and including Wales, Scotland, and

  • Question on using dialog functions

    When I use some dialog function, such as two button dialog box, can I change some properties, such as the size of popup widow, font size and color? I just want to make some more friendly and professional interface of my application to users. Thanks. 

  • How to disable the print icon on check status screen of shopping cart inSRM

    Hi Experts, I have a requirment in which I need to disable print Icon on the status screen of the shopping cart. Can anybody please let me know how to achive this requirement. Thanks, Arun K Singarapu

  • Restoring iPod - Can't get any songs on it!!!

    I plugged my iPod in and it completley wiped my iPod - not my iTunes. I follwed the instructions and pressed the restore button although when i did it - it said that my music was in use by another application so it said again that i had to restore my

  • AI went to grayscale CS5

    New to AI.  My computer went to grayscale, but prints color.  How do I get back to color. thanks Mike