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

Similar Messages

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

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

  • Problem calling a Java Method from C++

    hi everyone,
    i'm using JNI and i'm trying to call a Java method from C++, this is the code:
    SocketC.java
    public class SocketC
    private native void conectaServidor();
    private void recibeBuffer()
    System.out.println("HELLO!!!");
    public static void main(String args[])
    SocketC SC = new SocketC();
    SC.conectaServidor();
    static {
    System.loadLibrary("Server_TCP");
    Server_TCP.cpp
    char* recibirSock()
         int _flag = 1;
         while(_flag != 0)
              memset(buffer,0,sizeof(buffer));//Et la, celle pour recevoir
              recv(sock,buffer,sizeof(buffer),0);
              printf(" Mensaje del cliente: %s\n",buffer);
              _flag = strcmp(buffer,"salir");
         }//fin while
         return buffer;
    void enviarSock()
         int _flag = 1;
         getchar();
         while(_flag != 0)
              memset(buffer,0,sizeof(buffer));//procedimiento para enviar
              printf("\n Escriba: ");
              gets(buffer);
         //     err=scanf("%s",buffer);
              send(sock,buffer,sizeof(buffer),0);
              _flag = strcmp(buffer,"salir");
         }//fin while
    }//fin enviarSock
    DWORD servicio(LPVOID lpvoid)//
         char *buf;
         printf("\n Cliente aceptado!!!!!\n");
         buf=recibirSock();
         return 0;
    JNIEXPORT void JNICALL Java_SocketC_conectaServidor(JNIEnv *env, jobject obj)
    //void main()
    /*this is the problem i'm calling the method recibeBuffer*/
         jclass cls = env->GetObjectClass(obj);
         jmethodID mmid = env->GetMethodID(cls, "recibeBuffer", "(V)V");
         if (mmid == 0)
              return;
         env->CallVoidMethod(obj, mmid); //llama a Java
         WSAStartup(MAKEWORD(2,0),&wsa);//MAKEWORD dit qu'on utilise la version 2 de winsock
         printf("TCP conexion Sockets\n\n");
         //estimez vous heureux que je foute pas de copyright ;)
         system("TITLE TCP Conexion Sockets (Version server)");
         //fo avouer que c'est plus joli
         int port;
         printf("Port : ");//On demande juste le port, pas besoin d'ip on est sur un server
         scanf("%i",&port);
         sinserv.sin_family=AF_INET;     //Je ne connais pas d'autres familles
         sinserv.sin_addr.s_addr=INADDR_ANY;//Pas besoin d'ip pour le server
         sinserv.sin_port=htons(port);
         server=socket(AF_INET,SOCK_STREAM,0);//On construit le server
         //SOCK_STREAM pour le TCP
         bind(server,(SOCKADDR*)&sinserv,sizeof(sinserv));
         //On lie les parametres du socket avec le socket lui meme
         listen(server,SOMAXCONN);//On se met � �couter avec server, 0 pour n'accepter qu'une seule connection
         printf(" Servidor conectado.");
         while(1)
              sinsize=sizeof(sin);
              if((sock=accept(server,(SOCKADDR*)&sin,&sinsize))!=INVALID_SOCKET)
              {//accept : acepta cualquier conexion
                   if (hReadThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)
                   servicio, 0, 0, &dwThreadID))
                        printf("\nHOLA!");
                        GetExitCodeThread(hReadThread,&dwExitCode);
                        CloseHandle (hReadThread);
                   else
                        // Could not create the read thread.
                        printf("No se pudo crear");
                        exit(0);
    when i'm running the proyect i get this error:
    C:\POT Files\UCAB\tesis\esmart\french>java SocketC
    Exception in thread "main" java.lang.NoSuchMethodError: recibeBuffer
    at SocketC.conectaServidor(Native Method)
    at SocketC.main(SocketC.java:16)
    i don't know why this is happening i got declare the method recibeBuffer in my SocketC.java class, but doesn;t work can anyone help me?
    PD: sorry for my bad english i'm from Venezuela

    Next time please paste your code between &#91;code&#93; tags with the code button just above the edit message area.
    To answer your question, you wrote the wrong method signature. It should be:jmethodID mmid = env->GetMethodID(cls, "recibeBuffer", "()V");Regards

  • 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?

  • Invoking a Java Method from Peoplecode

    Hello,
    We are tasked to do a Single Sign On from a third-party to PeopleSoft HRHD using 3DES encryption method based from the email of the user from the third party. We managed to get the java program that was used to encrypt the email and use this to process the decryption on the Peoplesoft side.
    First, are we correct in enabling the SignOn Peoplecode and then creating a Record Peoplecode that process the encrypted string that was passed via the URL?
    Supposing we are correct in this first step, how do we call this java method? We have placed the java class in the PS_HOME/appserv/classes directory and we are somehow stuck on this part of the Peoplecode.
    <Peoplecode>
    &oDecrypt = CreateJavaObject("SSOCrpyto");
    &strDecEmail=&oDecrypt.decryptString(&strEncEmail);
    The decryptString part of the Java class is constructed like this.
    public String decryptString(byte[] message) throws Exception {
    ...code here...
    We are not familiar on how the parameter is passed when the datatype in java is an array of byte[] (If I understood it correctly).
    Thank you.
    Jeremy Leung
    Edited by: 934351 on May 15, 2012 12:36 AM

    Hello Hakan and Jim. Thank you for your replies. I, however, was wondering where do the method decryptString come in, in the Peoplecode? Pardon me if I post the entire Java class here. I am not very well-versed with the Java language, but upon reading most Java-related programs regarding Encryption/Decryption they are identical with the Java class pasted below.
    import java.security.MessageDigest;
    import javax.crypto.Cipher;
    import javax.crypto.SecretKey;
    import javax.crypto.spec.IvParameterSpec;
    import javax.crypto.spec.SecretKeySpec;
    public class SAPSSOCrypto {
         public byte[] encrypt(String message) throws Exception {
              final MessageDigest md = MessageDigest.getInstance("md5");
              final byte[] digestOfPassword =
                   md.digest("password".getBytes("utf-8"));
              final byte[] keyBytes = new byte[24];//Arrays.copyOf(digestOfPassword, 24);
              System.arraycopy(digestOfPassword,0,keyBytes,0,digestOfPassword.length);
              for (int j = 0, k = 16; j < 8;) {
                   keyBytes[k++] = keyBytes[j++];
              final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
              final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
              final Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
              cipher.init(Cipher.ENCRYPT_MODE, key, iv);
              final byte[] plainTextBytes = message.getBytes("utf-8");
              final byte[] cipherText = cipher.doFinal(plainTextBytes);
              // final String encodedCipherText = new sun.misc.BASE64Encoder()
              // .encode(cipherText);
              return cipherText;
         public String decryptString(byte[] message) throws Exception {
              final MessageDigest md = MessageDigest.getInstance("md5");
              final byte[] digestOfPassword =
                   md.digest("password".getBytes("utf-8"));
              final byte[] keyBytes = new byte[24]; //Arrays.copyOf(digestOfPassword, 24);
              System.arraycopy(digestOfPassword,0,keyBytes,0,digestOfPassword.length);
              for (int j = 0, k = 16; j < 8;) {
                   keyBytes[k++] = keyBytes[j++];
              final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
              final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
              final Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
              decipher.init(Cipher.DECRYPT_MODE, key, iv);
              // final byte[] encData = new // sun.misc.BASE64Decoder().decodeBuffer(message);
              final byte[] plainText = decipher.doFinal(message);
              return new String(plainText, "UTF-8");
    }

  • 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.

  • Invoking Applet methods from Javascript for Netscape 6

    Hi,
    I am trying to invoke an applet method from javascript, but it is failing with Netscape 6 browser:
    I am doing it the following way-
    function test(form)
    var i = document.myapplet.getname();
    where myapplet is the name of the applet and getname is a method within the applet. This is
    working with Ie but not with netscape 6.
    I would appreciate it if someone could tell me how should I invoke the applet method for netscape browsers.
    Thanks.
    Jay Srin.

    Not working with NS 6 - and will not i guess till they upgrade to Mozilla Version 1.0 - Live Connect is not implemented 100% correct yet - if you want you can download the 7.0 Pre Release Netscape - since its using mozilla 1.0 it should work , see :
    http://forum.java.sun.com/thread.jsp?forum=30&thread=272975

  • 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

Maybe you are looking for

  • Pricing determination for free goods

    Hi Experts, Please help me for the following issue: This is with regarding pricing determination. I have a requirement that, for each 10 quantities of Material ABC sold out, 3 quantities of same material ABC is given free. In VBN1, I have set the req

  • Flash builder 4.7 Eclipse 4.2.2 toolbar errors

    Hello, I installed the FB 4.7 as an Eclipse plugin in 4.2.2 but when trying to customize the perspective I've lost all toolbars buttons and Eclipse displays lot of errors from FB: !ENTRY org.eclipse.ui 4 4 2013-06-13 13:43:22.587 !MESSAGE Plug-in 'co

  • Asset Write Up Book Value

    Hi, We need to write up an asset , but the book value of the asset and not the depreciations. Looking in the ABZU it seems that all the transaction type, are connected with depreciations write-up. Using any transaction type, it seems that the depreci

  • Reading from graph to text file in labview 7.0

    Hi Guys! I am doing a project which reads analog values from a microprocessor board and I am using the Labview example Cont Acq&Graph Voltage-Int Clk.vi. I am getting an analogue graph using this VI. is there any way I can convert the values on the g

  • Flex + amf php server deployment problem

    Hi all, After almost a month of research on this problem. I was able to remove all my errors on production but still not able to retrieve data. Please help...... Here is the scenerio details : I created a form which will take input from user and stor