Native function call halting my program execution...

Well, I successfully got a an audio DLL made with JNI/SDL. This little program basically just runs until it finishes a song, then terminates.
Problem is that the program waits for it to finish.
I tried this:
class MusicThread extends Thread{
     public native boolean startMusic();
     public native void    endMusic();
     public MusicThread(pumpkin owner){
          super(owner);
     public void start(){
          startMusic();
}Hoping it would cause Java to run the thread seperatly, but that doesn't work. The only thing I can think of is having the DLL itself open the new thread, but I would like to explorer java options first.
Is there some way I can get it to not wait until my DLL function stops running to continue?
Does it have to be done on the C++ side?

Alright, everything up and working.
I can't believe how helpful this board is. Thanks to you guys I have an increasingly impressive looking game that will soon have an entire SDL sound library!
Thanks a ton!

Similar Messages

  • Native function call

    I created a native c class which is called in a java code. when i try to execute the program , there is "java.lang.UnsatisfiedLinkError". I tried to place the dll file created in the appropriate directory, but still i get the same error.
    My java class( which tries to access the c class) is in a package which is inside another directory, will this create any problem?
    kindly help me with ur suggestions. thank you

    I am attaching the code fragments below:
    package JavaFem;
         public class FESAMDSolver extends FESolver {
         public native void cAMDorder(int neq, int[]ap, int[]ai, int[]pv);
              static {
              //System.loadLibrary("testamd");
              System.load("Z:/testamd.dll");
              public void solve() {
         cAMDorder(num_eqns, Ap, Ai, pVector); // calling the native C method
    My native function code :
    #include <jni.h>
    #include "JavaFem_0005cFESAMDSolver.h"
    #include "amd.h"
    JNIEXPORT void JNICALL Java_JavaFem_0005cFESAMDSolver_cAMDorder
    (JNIEnv *env, jobject obj, jint n, jintArray ApArray , jintArray AiArray, jintArray PArray)
              jintArray Ap = (*env)->GetIntArrayElements(env, ApArray, 0);
              jintArray Ai = (*env)->GetIntArrayElements(env, AiArray, 0);
              jintArray P = (*env)->GetIntArrayElements(env, PArray, 0);
              (void) amd_order (n, Ap, Ai, P, (double *) NULL, (double *) NULL) ;
    Directory structure
    JavaFemViewer\JavaFem
         JavaFem is a package inside the JavaFemViewer folder.
    My testamd.dll file and all C file objs are located inside the JavaFem directory. When i created a dll file, there was no header file generated along with it.
    The error i get is displayed below:
    java.lang.UnsatisfiedLinkError: cAMDorder
    at JavaFem.FESAMDSolver.cAMDorder(Native Method)

  • Exit handling in native function by JNI

    Hi everyone,
    We are developing a Java application using native function calls through JNI in Linux.
    The application starts and calls a native function and the native function attach a signal
    handler and an exit handler. In addition, in the native function, we fork another process
    and in the forked process, we calls a several java-side methods. It works in normal cases.
    However, when System.exit() is called in the java-side methods invoked by a native function,
    the application is stopped. Thus we add shutdown hook (Runtime.getRuntime().addShutdownHook())
    to treat this case. The shutdown hook just calls a native method, and the native method
    just calls exit(). We expect the calling exit() in the native method invoked in shutdown hook for JVM
    invokes our exit handler which is attached in advance. It looks working well.
    But, sometimes we find several garbage(?) jvm processes (we can see the process named as "java"
    in using Linux command "ps"). The parent process of these processes is init process (pid = 1).
    With the pid of these processes, we suspect the processes are created when we fork another process
    in native function invoked through JNI. However it is not happened every times in our application.
    Why the garbage java processes remain? Is there any problem in the calling exit() in the native
    method invoked during JVM Shutdown process?
    I hope any answers for this problem.
    Thanks in advance,
    Seung-Uk Oh

    Thus we add shutdown hook
    (Runtime.getRuntime().addShutdownHook())
    to treat this case. The shutdown hook just calls a
    native method, and the native method
    just calls exit(). We expect the calling exit() in the
    native method invoked in shutdown hook for JVM
    invokes our exit handler which is attached in advance.
    It looks working well.I wouldn't think that was a good idea.
    You are terminating the JVMs normal exit process. Why don't you just register the exit processes in your own stack and call them with the native method?

  • Premiere CS5: R6025 - pure virtual function call

    When I go to render the sequence, I get:R6025 - pure virtual function call and the program crashes.
    the problem details are reporting:
    Problem Event Name:    APPCRASH
      Application Name:    Adobe Premiere Pro.exe
      Application Version:    5.0.0.0
      Application Timestamp:    4bb568b7
      Fault Module Name:    Backend.dll
      Fault Module Version:    5.0.0.0
      Fault Module Timestamp:    4bb529dd
      Exception Code:    40000015
      Exception Offset:    00000000001ba7eb
      OS Version:    6.0.6001.2.1.0.256.6
      Locale ID:    1033
      Additional Information 1:    603b
      Additional Information 2:    3ec9d140f10efeb2f0a7d02f968c360a
      Additional Information 3:    a863
      Additional Information 4:    75c6e9df8ab75d63002e907cb106c2fa
    Running Vista 64bit on a Dell T7400 with 12GB ram and Raid HDD's
    Any thoughts?
    Thanks
    Paul

    I'm having the same issue:
    Faulting application name: Adobe Premiere Pro.exe, version: 5.0.1.0, time stamp: 0x4bf119d2
    Faulting module name: Backend.dll, version: 5.0.1.0, time stamp: 0x4bf0dba0
    Exception code: 0x40000015
    Fault offset: 0x00000000001baafb
    Faulting process id: 0x15a8
    Faulting application start time: 0x01cb1b96d983de39
    Faulting application path: C:\Program Files\Adobe\Adobe Premiere Pro CS5\Adobe Premiere Pro.exe
    Faulting module path: C:\Program Files\Adobe\Adobe Premiere Pro CS5\Backend.dll
    Report Id: 6d0f1532-878a-11df-a3c5-81e14690b8b6
    Crashing during rendering.
    I 'm running Windows 7, 64 bit, Dell Covet 6400, Nvida Quadro FX3700M, 4gb ram.
    Issue occurs at the same frame, 802 of 2961 everytime I make at attempt to render.I've also noticed the Premier remains in memory after the crash.
    Has this been reported to Adobe or added to the bus list? If not, any idea how to get it added?
    thanks

  • UnsatisfiedLinkError with function call

    Hi,
    I am using JNI to make native function calls from Java.
    I use
    System.loadLibrary("myLibName");
    to load my library, and that works without a problem.
    I can use this library without any problems from a simple test app I wrote. However, I get an UnsatisfiedLinkError when I try and integrate with the rest of my applicaton. I am 100% certain that function is defined correctly in both Java and C++.
    The only difference I can think of between my real application (which does not work) and my test application (which does work) is that in my real application, the object that makes use of the class that contains all my native methods is cloned before it makes any calls to my native code.
    What can cause an UnsatisfiedLinkError if my System.loadLibrary() is correct, and my function definitions are also correct?
    Thanks!
    Eliott
    Edited by: EliottH on Mar 1, 2010 12:17 PM

    In case my post needs any clarification, here is some sample code that demonstrates what I am doing:
    //An instance of this class gets cloned before any native function calls are made!
    public class SomeClass implements Cloneable {
        JniClass jniclass;
        SomeClass() {
               jniclass = new JniClass();
        //This returns an UnsatisfiedLinkError when called
        public void func() {
                jniclass.nativeFunc1();
        public void clone() {
              //Something....
    public class JniClass {
        public native void nativeFunc1();
        static {
             System.loadLibrary("myLibName");
    }Edited by: EliottH on Mar 1, 2010 1:00 PM

  • SNMP4J- where is processPdu called in the program?

    Hello Everyone,
    I’ve made the simplest possible agent just to check if it can respond to the PDUs received from the manager. Although I’ve written the following code with the help of the SNMP4J tutorials, I have my doubt as to where is the processPdu function called in the program? I’ve written it fine, but I don’t see it being called. Thus, where is it that the PDU sent from the manager is actually received? Following is my code and the errors it generates. Please tell me where I’m going wrong. Also, since i'm working on Eclipse IDE, it seems quite confusing to me how to execute manager and agent together in order to create a communication session( just da way v do in socket programming). it seems that i can only run either of them at a time..
    public class SNMP4J_AGENT extends Thread implements CommandResponder
    * @param args
    // Processes incoming Pdu
    public synchronized void processPdu(CommandResponderEvent e)
    System.out.println("Command");
    ScopedPDU command;
    if ( e.getPDU() instanceof ScopedPDU)
    command = (ScopedPDU)e.getPDU();
    else
    command = (ScopedPDU)e.getPDU();
    if (command != null)
    //send reply
    ScopedPDU cmd = (ScopedPDU)e.getPDU();
    cmd.setType(ScopedPDU.RESPONSE);
    cmd.setRequestID(command.getRequestID());
    StatusInformation st=new StatusInformation(new VariableBinding(),
    e.getStateReference().getContextName(),
    e.getStateReference().getContextEngineID(),
    new Integer32( e.getStateReference().getSecurityLevel()) );
    StatusInformation statusInformation = new StatusInformation();
    StateReference ref = e.getStateReference();
    System.out.println(ref);
    try
    e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(),
    e.getSecurityModel(),
    e.getSecurityName(),
    e.getSecurityLevel(),
    command,
    e.getMaxSizeResponsePDU(),
    ref,
    st);
    System.out.println("Response sent to manager....");
    catch (MessageException e1)
    e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates
    @Override
    public void run()
    //InetAddress hostIp;
    //int port_, version;
    try
    //Sets the snmp listener to port
    TransportMapping transport = new DefaultUdpTransportMapping(new UdpAddress("udp:127.0.0.1/161"));
    Snmp snmp = new Snmp(transport); //snmp.addCommandResponder(this);
    MPv3 mpv3 = (MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
    System.out.println("in try");
    //if (version == 3)
    byte[] localEngineID =((MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3)).createLocalEngineID();
    USM usm = new USM(SecurityProtocols.getInstance(),
    new OctetString(localEngineID),0);
    SecurityModels.getInstance().addSecurityModel(usm);
    snmp.setLocalEngine(localEngineID, 0, 0);
    // Add the configured user to the USM
    snmp.getUSM().addUser(new OctetString("MD5DES"),
    new UsmUser(new OctetString("MD5DES"),
    AuthMD5.ID,
    new OctetString("MD5DESUserAuthPassword"),
    PrivDES.ID ,
    new OctetString("MD5DESUserPrivPassword")));
    System.out.println("USM: "+ snmp.getUSM());
    snmp.addCommandResponder(this);
    //snmp.listen();
    // md.addCommandResponder(this);
    System.out.println("transportBinding..");
    transport.listen();
    // transport.listen();
    System.out.print("SNMP Listener init: ");
    Address a = transport.getListenAddress();
    System.out.println(a.toString());
    //snmp.processPdu(this);
    /* try
    snmp.processPdu(arg0);
    catch(Exception ex)
    ex.getMessage();
    snmp.close();
    catch (IOException e)
    System.err.print("ERROR!!!!! "+e);
    try
    this.wait();
    catch (InterruptedException ex)
    Thread.currentThread().interrupt();
    public static void main(String[] args)throws Exception
    // TODO Auto-generated method stub
    new SNMP4J_AGENT().start();
    Errors:
    Exception in thread "Thread-0" java.lang.IllegalArgumentException: udp:127.0.0.1/161
    at org.snmp4j.smi.UdpAddress.<init>(UdpAddress.java:48)
    at SNMP4J_AGENT.run(SNMP4J_AGENT.java:100)
    Thanx a lot…..
    Regards,
    Nidhi Lohat,
    Software Trainee,
    Eminent Networks Pvt. Ltd.(HFCL Group)

    Hello Everyone,
    I’ve made the simplest possible agent just to check if it can respond to the PDUs received from the manager. Although I’ve written the following code with the help of the SNMP4J tutorials, I have my doubt as to where is the processPdu function called in the program? I’ve written it fine, but I don’t see it being called. Thus, where is it that the PDU sent from the manager is actually received? Following is my code and the errors it generates. Please tell me where I’m going wrong. Also, since i'm working on Eclipse IDE, it seems quite confusing to me how to execute manager and agent together in order to create a communication session( just da way v do in socket programming). it seems that i can only run either of them at a time..
    public class SNMP4J_AGENT extends Thread implements CommandResponder
    * @param args
    // Processes incoming Pdu
    public synchronized void processPdu(CommandResponderEvent e)
    System.out.println("Command");
    ScopedPDU command;
    if ( e.getPDU() instanceof ScopedPDU)
    command = (ScopedPDU)e.getPDU();
    else
    command = (ScopedPDU)e.getPDU();
    if (command != null)
    //send reply
    ScopedPDU cmd = (ScopedPDU)e.getPDU();
    cmd.setType(ScopedPDU.RESPONSE);
    cmd.setRequestID(command.getRequestID());
    StatusInformation st=new StatusInformation(new VariableBinding(),
    e.getStateReference().getContextName(),
    e.getStateReference().getContextEngineID(),
    new Integer32( e.getStateReference().getSecurityLevel()) );
    StatusInformation statusInformation = new StatusInformation();
    StateReference ref = e.getStateReference();
    System.out.println(ref);
    try
    e.getMessageDispatcher().returnResponsePdu(e.getMessageProcessingModel(),
    e.getSecurityModel(),
    e.getSecurityName(),
    e.getSecurityLevel(),
    command,
    e.getMaxSizeResponsePDU(),
    ref,
    st);
    System.out.println("Response sent to manager....");
    catch (MessageException e1)
    e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates
    @Override
    public void run()
    //InetAddress hostIp;
    //int port_, version;
    try
    //Sets the snmp listener to port
    TransportMapping transport = new DefaultUdpTransportMapping(new UdpAddress("udp:127.0.0.1/161"));
    Snmp snmp = new Snmp(transport); //snmp.addCommandResponder(this);
    MPv3 mpv3 = (MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3);
    System.out.println("in try");
    //if (version == 3)
    byte[] localEngineID =((MPv3)snmp.getMessageProcessingModel(MessageProcessingModel.MPv3)).createLocalEngineID();
    USM usm = new USM(SecurityProtocols.getInstance(),
    new OctetString(localEngineID),0);
    SecurityModels.getInstance().addSecurityModel(usm);
    snmp.setLocalEngine(localEngineID, 0, 0);
    // Add the configured user to the USM
    snmp.getUSM().addUser(new OctetString("MD5DES"),
    new UsmUser(new OctetString("MD5DES"),
    AuthMD5.ID,
    new OctetString("MD5DESUserAuthPassword"),
    PrivDES.ID ,
    new OctetString("MD5DESUserPrivPassword")));
    System.out.println("USM: "+ snmp.getUSM());
    snmp.addCommandResponder(this);
    //snmp.listen();
    // md.addCommandResponder(this);
    System.out.println("transportBinding..");
    transport.listen();
    // transport.listen();
    System.out.print("SNMP Listener init: ");
    Address a = transport.getListenAddress();
    System.out.println(a.toString());
    //snmp.processPdu(this);
    /* try
    snmp.processPdu(arg0);
    catch(Exception ex)
    ex.getMessage();
    snmp.close();
    catch (IOException e)
    System.err.print("ERROR!!!!! "+e);
    try
    this.wait();
    catch (InterruptedException ex)
    Thread.currentThread().interrupt();
    public static void main(String[] args)throws Exception
    // TODO Auto-generated method stub
    new SNMP4J_AGENT().start();
    Errors:
    Exception in thread "Thread-0" java.lang.IllegalArgumentException: udp:127.0.0.1/161
    at org.snmp4j.smi.UdpAddress.<init>(UdpAddress.java:48)
    at SNMP4J_AGENT.run(SNMP4J_AGENT.java:100)
    Thanx a lot…..
    Regards,
    Nidhi Lohat,
    Software Trainee,
    Eminent Networks Pvt. Ltd.(HFCL Group)

  • The order of execution (of PL/SQL function calls) changes...why??

    select e.EMPID empid,
    e.name name,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e
    where e.empid = 101
    order by e.name;
    when I execute this select statement...the order of function calls is as follows:
    setvalues 1st (call no:1)
    test1 (call no:2)
    test2 (call no:3)
    test3 (call no:4)
    Now...I introduce a join between the two tacles as mentioned in the query
    select e.EMPID empid,
    e.name name,
    e2.deptno deptid,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e, emp2 e2
    where e.empid = e2.empid
    order by e.name;
    The order of execution of function calls changes to
    (I observed this using DBMS_OUTPUT.PUT_LINE)
    test3 (call no:1)
    setvalues 1st (call no:2)
    test1 (call no:3)
    test2 (call no:4) (the first and last calls swap!)
    i.e: it calls the last function in the select statement at the beginning
    instead of calling it at the last. Is it the normal behaviour? or whats going on
    here?
    Can somebody explain me, please....
    Details:
    the following four functions are defined in a package called 'aatest' and compiled.
    aatest.SETVALUES(2)
    aatest.TEST1()
    aatest.TEST2()
    aatest.TEST3()
    the Tables EMP and EMP2 are two tables defined in the same schema.

    Your "thinking" is wrong here. You can not use the column order to model your program flow. As SQL is set/tupel based, there is no given sequence of the execution order. Otoh you want to have a specific order in wich your functions must be executed otherwise the result will be wrong (or undefined). Thus here you need a procedural approach. This can be done by using PL/SQL for example.
    You would code your functions in that way, that they are working correctly independent from the place where they are called ie if function1 needs the setvalues function, this function must be called inside the function1 then.
    Are you sure you need all these functions in this procedural approach inside the sql-statement? This is mostly not needed and can be accomplished by using pure SQL. If not, may be your design is broken.

  • How can I call a C program or call a C function in my JAVA code?

    Could I call a C program or a C function in my JAVA code?
    somebody told me that I should define a native() method, but what should I do in this native() method?
    could u give me an example?
    thanks in advance.

    Maybe these will give a clue:
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    http://java.sun.com/j2se/1.3/docs/guide/jni/

  • Call native function fflush & strprn from java

    Hi,
    I need to call a native function fflush and stdprn from java for printing a file.
    How can i call this function?
    Can any one help me with sample code.
    Thanks,
    rpalanivelu

    Thanks your reply,
    Actually my problem is need to take printout using dot matrix printer(text printer) with different font size.
    So, i am using native method which is available in c.
    in c program i am using fflush,stdprn and fprintf.
    Here i've attached my sample program also.
    #include <jni.h>
    #include "NativePrint.h"
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #define MAXLINE_LEN 100
    JNIEXPORT jint JNICALL
    Java_NativePrint_dotMatrixPrint(JNIEnv* env, jobject obj )
    FILE *fp;
    char filename[20];
    char line[100]; /* A line read from the file */
    int lineNumber = 0;
    /* Print control codes */
    char boldOn = 14;
    char boldOff = 20;
    char contentlenOn = 15;
    char contentlenOff = 18;
    printf("Printing from C3");
    strcpy( filename , "sayHello.c" );
    /* Open the file in read mode */
    fp = fopen( filename , "r" );
    /* Error in opening file, then exit */
    if ( fp == NULL )
    printf( "\nERROR: %s cannot be opened\n" , filename );
    exit( 1 );
    while ( fgets( line , 100 , fp ) != NULL )
    lineNumber++; /* Line we are about to process next */
    printf("%s",line);
    /* If this is the first line */
    if ( lineNumber == 1 )
    /* then print it in bold */
    //fprintf( stdprn , "%c" , boldOn );
    fprintf( stdprn , "%c" , contentlenOn );
    fprintf( stdprn , line );
    fprintf( stdprn , "%c" , contentlenOff);
    //fprintf( stdprn , "%c" , boldOff );
    else
    /* else print it in normal mode */
    fprintf( stdprn , line );
    fflush(stdprn);
    return 0;

  • When i open my i3tunes on my computer i get an error message telling me that iTunes has stopped working..the message is as follows...Microsoft Visual C  runtime library Program C:\program files (86) iTunes\iTunes.exe  R6025 -Pure virtual function call..

    when i open my i3tunes on my computer i get an error message telling me that iTunes has stopped working..the message is as follows...Microsoft Visual C  runtime library Program C:\program files (86) iTunes\iTunes.exe  R6025 -Pure virtual function call.. How do i fix this

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • ITunes crashes when doing a power search. I get a Microsoft Visual C   Runtime Library Error message: Program C:\Program Files (x86)\iTunes\iTunes.exe R6025.  Pure virtual functional call.  If I select ok, Windows 7 pops up with iTunes has stopped working

    iTunes crashes when doing a power search. I get a Microsoft Visual C   Runtime Library Error message: Program C:\Program Files (x86)\iTunes\iTunes.exe R6025.  Pure virtual functional call.  If I select ok, Windows 7 pops up with iTunes has stopped working and then it shuts iTunes down.  Anyone else every have this issue.  Any ideas on a fix?
    Thanks,

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • Call an executable program inside function module and pass the table values

    Hi,
           i'm pretty new to HR Abap programming. I have a requirement like "calling an executable program within a function module and the output of the program data(Stored in internal tables) should be passed to the function module tables".
    I've some idea about SUBMIT keyword and i used it in the function module..
    Please do the needful to solve this.
    Regards,
    Selvi.

    Hi,
    Thanks for all your reply.
      I've used Option 3 as per dsouzajovito suggestion. Now i'm getting data in function module tables using import/ export table to memory concept.
    Again a small issue arises, while i'm executing function module it fetches all pernr available in the server and displays the details of last pernr. GET pernr statement is used in the Z report and submit statement is used like this as follows.
      SUBMIT ZHR_RFC_PAYSLIP   WITH  PERNR-PERNR EQ EMPCODE
                                          WITH PYBEGDA EQ FDATE
                                          WITH PYENDDA EQ LDATE
                                          AND RETURN.
    Pls suggest if there is any corrections in the code.
    If i give a pernr as input in the function module, then it should fetch the details related only to that pernr.
    FYI, No selection screen is used here as per requirement.
    Regards,
    Selvi.

  • When trying to download jave have runtime error progran c:/program files/mozella\firefox exe R6205 - pure virtual function call

    I have been having problems logging in and had to go to system set not quite knowing what I am doing I sent and changed to configure default, then when I went in my plugin crashed so I tried to update java again an got the above area message,Runtime error program c:/ program files\mozilla\firefox\firefox exe R6205 -pure virtual function call. I also tried to update my driver but as soon as they started checking updates mozilla shut down

    Try checking this guide on [http://www.pcperformancetools.com/runtimeerrors.htm
    runtime error download] It discusses step-by-step instructions on how to diagnose and repair windows runtime problems. They also got a free tool to clean-out and repair corrupt associations in the Windows Registry automatically.

  • Calling native functions from java w/out DLL

    If I invoke a JVM inside my c++ app and try to start up a class that calls a native function, do I still need a DLL for that? Or will it look to my header file and then look to my implementation somewhere in a c++ class?
    For example:
    WinMain() - Invokes JVM and loads "HelloWorld" java class, then calls its 'main' method.
    HelloWorld.java - 'main' method calls "displayHello();" a native function.
    HelloWorld.h - defines displayHello native interface
    So it looks simply to the cpp implementation of the interface...I tried executing this but it isnt working...is it even possible?

    OK, I attempted what you posted by writing the following code... please look at because I get a 'main' not found error. I am trying to execute this from a win32 app...
    Callbacks.java:
    class Callbacks {
      private native void nativeMethod(int depth);
      private void callback(int depth) {
        if (depth < 5) {
          System.out.println("In Java, depth = " + depth + ", about to enter C");
          nativeMethod(depth + 1);
          System.out.println("In Java, depth = " + depth + ", back from C");
        } else
          System.out.println("In Java, depth = " + depth + ", limit exceeded");
      public static void main(String args[]) {
        Callbacks c = new Callbacks();
        c.nativeMethod(0);
    }InvokeJVM.cpp:
    #include "InvokeJVM.h"
    //Log any windows errors
    void InvokeJVM::LogWin32Error(const char * pTitle){
         PCHAR pBuffer;   
         LONG  lError = GetLastError ( );
         FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
              NULL,                   
              lError,                   
              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),                   
              (char *)&pBuffer,                   
              0,                   
              NULL );
         //LogError ("Win32 error: %s %s\n",pBuffer,pTitle);
         LocalFree ( pBuffer );
    //Get a string returned from the windows registry
    bool InvokeJVM::GetStringFromRegistry(HKEY key, const char *name, unsigned char *buf, int bufsize){
         DWORD type, size;
         if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 && type == REG_SZ && (size < (unsigned int)bufsize)){
              if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0){
                   return true;
         return false;
    //Get the path to the runtime environment
    bool InvokeJVM::GetPublicJREHome(char *buf, int bufsize){
         HKEY key, subkey;   
         char version[MAX_PATH];  
         /* Find the current version of the JRE */
         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY,0,KEY_READ,&key)!=0){
              //LogError("Error opening registry key '" JRE_KEY "'\n");          
              return false;   
         if(!GetStringFromRegistry(key,"CurrentVersion",(unsigned char *)version, sizeof(version))){
              //LogError("Failed reading value of registry key:\n\t"JRE_KEY "\\CurrentVersion\n");          
              RegCloseKey(key);          
              return false;   
         if(strcmp(version, DOTRELEASE)!= 0){
              //LogError("Registry key '" JRE_KEY "\\CurrentVersion'\nhas value '%s', but '" DOTRELEASE "' is required.\n", version);
              RegCloseKey(key);          
              return false;   
         /* Find directory where the current version is installed. */   
         if(RegOpenKeyEx(key,version,0,KEY_READ, &subkey)!= 0){
              //LogError("Error opening registry key '"JRE_KEY "\\%s'\n", version);          
              RegCloseKey(key);          
              return false;   
         if(!GetStringFromRegistry(subkey, "JavaHome", (unsigned char *)buf, bufsize)){
              //LogError("Failed reading value of registry key:\n\t"JRE_KEY "\\%s\\JavaHome\n", version);          
              RegCloseKey(key);          
              RegCloseKey(subkey);          
              return false;   
         RegCloseKey(key);   
         RegCloseKey(subkey);   
         return true;
    //Native interface call to printf
    jint JNICALL _vfprintf_(FILE *fp, const char *format, va_list args){
         //LogError(format,args);     
         return 0;
    //Native interface call if the VM exited
    void JNICALL _exit_(jint code){     
         //LogError("VM exited");     
         exit(code);
    //Native interface call if the VM aborted
    void JNICALL _abort_(void){
         //LogError("VM aborted");     
         abort();
    //Load the Java Virtual Machine
    void InvokeJVM::LoadJVM(char* dir){
         HINSTANCE handle;     
         JavaVMOption options[5];     
         char JREHome[MAX_PATH];     
         char JVMPath[MAX_PATH];                                             
         char classpathOption[MAX_PATH];     
         char librarypathOption[MAX_PATH];
         if(!GetPublicJREHome(JREHome, MAX_PATH)){          
              //LogError("Could not locate JRE");          
              abort();     
         strcpy(JVMPath,JREHome);     
         strcat(JVMPath,"\\jre\\bin\\client\\jvm.dll");
         if ((handle=LoadLibrary(JVMPath))==0) {          
              //LogError("Error loading: %s", JVMPath);          
              abort();   
         CreateJavaVM_t pfnCreateJavaVM=(CreateJavaVM_t)GetProcAddress(handle,"JNI_CreateJavaVM");
         if (pfnCreateJavaVM==0){          
              //LogError("Error: can't find JNI interfaces in: %s",JVMPath);          
              abort();     
         strcpy(classpathOption,"-Djava.class.path=");
         strcat(classpathOption,dir);     
         strcat(classpathOption,";");     
         strcat(classpathOption,JREHome);     
         strcat(classpathOption,"\\lib");     
         strcat(classpathOption,";");
         strcat(classpathOption,JREHome);     
         strcat(classpathOption,"\\lib\\comm.jar");     
         strcpy(librarypathOption,"-Djava.library.path=");     
         strcat(librarypathOption,JREHome);     
         strcat(librarypathOption,"\\lib");
         OutputDebugString("classpath option=");     
         OutputDebugString(classpathOption);     
         OutputDebugString("\n");     
         OutputDebugString("librarypath option=");     
         OutputDebugString(librarypathOption);     
         OutputDebugString("\n");
         options[0].optionString=classpathOption;
         options[1].optionString=librarypathOption;          
         options[2].optionString="vfprintf";     
         options[2].extraInfo=_vfprintf_;     
         options[3].optionString="exit";     
         options[3].extraInfo=_exit_;     
         options[4].optionString="abort";     
         options[4].extraInfo=_abort_;
         vmArgs.version = JNI_VERSION_1_2;
         vmArgs.nOptions = 5;   
         vmArgs.options  = options;  
         vmArgs.ignoreUnrecognized = false;
         if(pfnCreateJavaVM(&jvm,(void**)&env, &vmArgs) != 0){
              //LogError("Could not create VM");
              abort();     
    }Winmain.cpp:
    #define WIN32_MEAN_AND_LEAN
    #define WIN32_EXTRA_LEAN
    #include <windows.h>
    #include "oglwindow.h"          // the OpenGL window class
    #include "vector.h"
    #include "engine.h"               // the engine's main class
    #include "BrimstoneEngine.h"
    #include "InvokeJVM.h"
    JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject){
        MessageBox(NULL, "Hello From Java!", "Error", MB_OK);
        return;
    JNIEXPORT void JNICALL Java_Callbacks_nativeMethod(JNIEnv *env, jobject obj, jint depth){
      jclass cls = env->GetObjectClass(obj);
      jmethodID mid = env->GetMethodID(cls, "callback", "(I)V");
      if (mid == 0) {
        return;
      printf("In C, depth = %d, about to enter Java\n", depth);
      env->CallVoidMethod(obj, mid, depth);
      printf("In C, depth = %d, back from Java\n", depth);
    JNINativeMethod methods[] = {"nativeMethod","()V", Java_Callbacks_nativeMethod};
    WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow){
         InvokeJVM javaVirtualMachine;
         int loopRet;
         javaVirtualMachine.running = false;
         CoInitialize(NULL);
         if (!COGLWindow::RegisterWindow(hInst)){
              MessageBox(NULL, "Failed to register window class", "Error", MB_OK);
              return -1;
         BrimstoneEngine *engine = NULL;
         try{
              char path[MAX_PATH];  
              char drive[MAX_PATH];   
              char file[MAX_PATH];   
              char dir[MAX_PATH];   
              char ext[MAX_PATH];
              jclass  cls, cls1;     
              jmethodID mid;     
              jobjectArray args;
              jint err;
              _splitpath(path,drive,dir,file,ext);          
              javaVirtualMachine.LoadJVM(dir);     
              if(javaVirtualMachine.env == NULL){               
                   MessageBox(NULL, "Could not load VM", "Error", MB_OK);
                   abort();          
              if(GetModuleFileName(NULL, path, MAX_PATH) == 0){               
                   javaVirtualMachine.LogWin32Error("Getting module filename");          
                   abort();          
              cls = javaVirtualMachine.env->FindClass("Callbacks");
              if(cls == NULL){               
                   MessageBox(NULL, "Could not find class %s (or its superclass)", "Error", MB_OK);
                   exit(-1);          
              err = javaVirtualMachine.env->RegisterNatives(cls, methods, 1 );
              mid = javaVirtualMachine.env->GetMethodID(cls, "main", "([Ljava/lang/String;)V");
              if(mid == NULL){
                   MessageBox(NULL, "Could not find method 'main'", "Error", MB_OK);
                   exit(-1);          
              args = javaVirtualMachine.env->NewObjectArray(2-2, javaVirtualMachine.env->FindClass("java/lang/String"), NULL);          
              if(args==NULL){               
                   MessageBox(NULL, "Could not create args array", "Error", MB_OK);
              for(int arg=0; arg < 2;arg++)     {               
                   javaVirtualMachine.env->SetObjectArrayElement(args, arg, javaVirtualMachine.env->NewStringUTF(argv[arg+2]));      
              javaVirtualMachine.env->CallStaticVoidMethod(cls,mid,args);     
              javaVirtualMachine.jvm->DestroyJavaVM();
              engine = new BrimstoneEngine("OpenGL Game", FALSE, 800, 600, 16);
              loopRet = engine->EnterMessageLoop();
              delete engine;
              return loopRet;
         catch(char *sz)
              MessageBox(NULL, sz, 0, 0);
              delete engine;
         CoUninitialize();
         return -1;
    }any help is always appreciated

  • Preloading and initialization of function calls brings response to a halt

    I am creating a form with many CFC calls to the server.
    However, on initial load, I am calling all these functions so that
    my detailregion which relies on the result set from these
    function calls would not error out. These initial functions do not
    return any results - there exist to satify the regiondetail
    bindings.
    Eg. my initialization calls
    var getEmployees = new Spry.Data.XMLDataSet(someCFCFile,
    "employees/employee_id", { useCache: false });
    var getDocs = new Spry.Data.XMLDataSet(someCFCFile,
    "employees/employee_id", { useCache: false });
    My issue is that the number of calls I am making are causing
    the page to take 15+ seconds to load. I can't do without them
    because my regiondetail rely on them initially. And also, later on,
    my code uses these variables to make other calls Eg.
    getEmployees .setURL(someCFCFile);
    I have tried to perform these initial call with a null value,
    but IE is still taking just as long to process these calls.
    Eg.
    var getEmployees = new Spry.Data.XMLDataSet(NULL,
    "employees/employee_id", { useCache: false });
    Please help. Thanks.

    Either Restrict Access or a Send Email Instance. Once I have tried to add either one of these to a page or successfully added, then I can't use ADDT at all.
    For instance I click on any of the Wizards to run them, I get a ADDT window with the word loading across it. It sits and spins.
    I have spent all afternoon trying to just get back to where I can work with ADDT again normally. The only way I have found that ADDT will work again after trying to utilize the email function or the Login function is to delete all of the ADDT include files and re-install.
    Not very time affective.

Maybe you are looking for