Calling native code from Flex

I was wondering, is there any way to call native code from Flex?
Currently, we're writing browser plugins in order to call native code from a Flex application. However, it would be nice to be able to call native code directly from Flex, so that we could write it only per-platform, as opposed to currently per-platform-per-browser.

In general, the sandbox does not allow you to access native code from Flex.
I believe you can use Merapi, but perhaps only for AIR:
http://www.merapiproject.net/
You might be able to code around the Flex sandbox, but it would be a ton of work.
If this post answers your question or helps, please mark it as such.

Similar Messages

  • Urgent - How to call native methods from J2ME

    Hi,
    I have to do some very heavy processing work, so I have my code written in C. And now I want these native functions to be called from a J2ME application. I had thought this was not possible and J2ME did not support something like JNI as J2SE did.
    However, when contacted with Sun Technical Support we were advised to use KNI in J2ME. I went through the KNI documentation and did not find any example to do so.
    On reading about it I understood that it cannot be implemented by developers as the native functions if any using KNI should be implemented while compiling the KVM.
    I would like to know whether my understanding is correct, or is it possible to call native functions from J2ME. Say I would like to have my native functions called from J2ME and run it on my Nokia N73 or other such phones.
    Experts please clear this.
    Regards,
    Kamalakshan

    Hi,
    You are right in your assumptions regarding KNI. Here is some related thread that might also help. There has been [some work|http://developer.symbian.com/main/downloads/papers/MIDlet_Native_Services_Framework/MIDlet_Native_Services_Framework_v1.1.zip] done in accessing native services through a MIDlet.
    Mihai

  • Calling native libraries from OC4J (howto config)

    Hello folks,
    I need your help. I am trying to set up OC4J so that I can call native libraries from my servlet. Could you point me to the respective documentation or give a hint on how to configure OC4J for this? Thank you.
    GKK

    gday GKK --
    I don't have an example, so I'm working from memory here and assuming you are using OC4J standalone.
    There's two aspects which need to be considered:
    1: the Java wrapper classes you have which call out to the native libary.
    2: the native libs themselves (which I'll call a .dll from hereon in for simplicity).
    What you would need to do is make sure the Java wrapper classes are all available to the web application. This can be done by either packaging them in a jar file and putting it into the web-inf/lib directory of your web application, or leaving them in an unpackaged form and putting it into the web-inf/classes directory.
    I do vaguely remember helping someone debug a JSP tag lib issue once before which used native code and we ran into some problems with concurrent use of the same DLL (a Java restriction) because a DLL can only be registered once per JVM instance and the threading model meant it was being loaded more than once -- but it may have also had something to do with the JSP taglib cache.
    If you do get some form of Java runtime exception showing concurrent access error for the native lib, what you can do is move the lib with the Java wrapper classes into the global classpath (j2ee/home/applib) meaning it's only ever loaded once..
    Then what you need to do is make sure the DLL itself is accessible to the Java process -- on Windows this is done by making sure directory holding the DDL is set in the PATH environment variable before -- before starting OC4J. On other platforms, it can be done using the LD_LIBRARY_PATH environment variable.
    That should be all you need to do to make it work.
    cheers
    -steve-

  • Error: There was a failure to call cluster code from a provider. Exception message: Generic failure . Status code: 5015. SQL 2012 SP1

    Hi,
    Please help. I was trying to remove a SQL 2012 SP1 two node clustered instance using setup (Mantenance -> Remove Node)
    I started by doing this on passive node (and was successful) but when I ran setup on active node just before finishing successfully I got this error:
    TITLE: Microsoft SQL Server 2012 Service Pack 1 Setup
    The following error has occurred:
    The resource 'BCK_SG1DB' could not be moved from cluster group 'SQL Server (SG1DB)' to cluster group 'Available Storage'. 
    Error: There was a failure to call cluster code from a provider. Exception message: Generic failure . Status code: 5015.
    Description: The operation failed because either the specified cluster node is not the owner of the resource, or the node
    is not a possible owner of the resource.
    For help, click:
    http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3000.0&EvtType=0xE8049925%25400x42B4DED7
    BUTTONS:
    OK
    I noticed that SG1DB instance was removed on both nodes but on Failover Cluster Manager -> Services and Applications the SQL server instance for SG1DB is still there. So I tried to delete it but got the error:
    Failed to delete SQL Server SG1DB. An error was encountered while deleting the cluster service or
    application SQL Server SG1DB. Could not move the resource to available storage. An error occured
    while moving the resource BCK_SG1DB to the clustered service or application Available Storage
    Any ideas why it failed or how could I delete the SQL server instance from Clauster?
    Thx

    Hello,
    Please read the following resource.
    https://support.microsoft.com/en-us/kb/kbview/313882?wa=wsignin1.0
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Calling Notes code from jre

    Hi All,
    I have a set of code that access the Lotus Notes database i am calling them by including the corresponding jar file inside Eclipse,but how do i perform the same operation by running JRE.
    Pls help me in this regard?
    Thanks in Advance

    Alternatively is there an easier way of calling .NET code from Oracle? Expose your .NET code as a web service. Oracle stored procedures are quite capable of invoking web services and working with XML responses.

  • Calling C++ code from Flash/Flex

    Hi everybody!
    Does anyone know how to call a DLL (C++) -function in Flex or
    Flash with Actionscript, or any other (easy?) way to access C++
    code?
    I love developing in Flex, but actionscript is an easy
    language with some restrictions, so that's why i'd really like to
    have C++ code in Flex/Flash. :)

    Calling out to a dll of C++ would break the Flash Player
    security model. So it is prohibited. Check out Adobe Labs and look
    at the AIR runtime. Air allows
    Flex applicationS to run as desktop applications not web
    application with the web type security restrictions.
    Also some folks are developing and open source way to
    integrate Java with air.
    http://artemis.effectiveui.com/

  • Setting native code from a class of a class passed in...

    I hope this makes sense, and its probably a stupid question but here it goes.
    I have a native function that takes in a java class. I can call the getters of this class from the native code to get values to fill out my c structure just fine, but conceptually I am not 100% how to call the getters of a class that is part of the other class I passed in. Basically i have something like this:
    the java call to the native being:
    public native void setJSource(JSource theSource);
    JNIEXPORT void JNICALL Java_AbfaRegion_setJSource
      (JNIEnv *env, jobject thisObj, jobject someVarsObj)
              jclass clazz;
              jmethodID mid;
              jint val;
              clazz = (*env)->GetObjectClass(env,someVarsObj);
              mid = (*env)->GetMethodID(env,clazz, "GetHeight", "I");
              val = (*env)->CallIntMethod(env,someVarsObj, mid);
              //put val into my struct
              mid = (*env)->GetMethodID(env,clazz, "GetWidth", "I");
              val=(*env)->CallIntMethod(env,someVarsObj, mid);
              //put val into my struct
    }I know how to do this...but what if I had a class say:
    class myClass
        JSource theSource; //has its own getters and setters like GetHeight
        int someVal;
        double anotherVal;
        public native void setMyClass(myClass theClass)
        int GetSomeVal()
          return this.someVal;
        int GetAnotherVal()
          return this.anotherVal;
        void SetSomeVal(int iSomeVal) 
          this.someVal=iSomeVal;
        void SetAnotherVal(double dAnotherVal)
          this.anotherVal=dAnotherVal;
    }and then suppose in the native setMyClass I would like to get the height of the jsource of myclass, how can i do that in native code, do I have to use findclass or something?
    Thanks for any help here, sorry if its a dumb question..
    -Shane

    For any class whose methods you are going to call, you need to first get a reference to the "class" record. So if you have an outer class, and have looked up its class record, and called a getter, and been returned an object (phew!):
    You need to now look up the class for the inner object; you can then look up the the methods and call them.
    JNI supports two ways to look up class:
    FindClass, where the key argument is the fully-qualified class name.
    GetObjectClass, where the key argument is an object reference.

  • Calling Web Service from Flex (to PeopleSoft)

    I'm new to Flex and web services. I've created a web service
    in PeopleSoft and successfully imported the WSDL into Flex so that
    it has contacted the PS server and returned data (using
    mx:WebService and mx:Operation code I found examples of). However,
    I have been unable to pass a parameter to the service from Flex
    using that code. I then discovered and followed the sample code in
    the Flex-generated package, but no matter what I do I cannot
    successfully supply the "myValue" in the sample shown below. Here
    is Flex's own text in my GetInfo.as file built by Flex:
    * MXML sample code:
    * First you need to map the package where the files were
    generated to a namespace, usually on the <mx:Application>
    tag, like this: xmlns:ws="com.draper.*"
    * Define the service and within its tags set the request
    wrapper for the desired operation
    * <ws:GetInfo id="myService">
    * <ws:FindID_request_var><ws:FindID_request
    Find__CompIntfc__DL_TREE_IB_CI=myValue/>
    * </ws:FindID_request_var>
    * </ws:GetInfo>
    * Then call the operation for which you have set the request
    wrapper value above, like this:
    * <mx:Button id="myButton" label="Call operation"
    click="myService.FindID_send()" />
    My code is:
    <ws:GetInfo id="userRequest">
    <ws:findID_request_var><ws:FindID_request
    Find__CompIntfc__DL_TREE_IB_CI="X"/>
    </ws:findID_request_var>
    </ws:GetInfo>
    When I try to run it, Flex is unhappy with the value I am
    assigning ("X" above) no matter what I put there. If I omit the
    double quotes and try to assign a text input field value (which is
    my goal here), it complains that it expects a double quote. If I
    put almost anything else there, it complains either:
    Initializer for 'Find__CompIntfc__DL_TREE_IB_CI'; values of
    type com.draper.Find__CompIntfc__DL_TREE_IB_CITypeShape cannot be
    represented as text.
    or, if I try this line, where I attempt to pass a text input
    field:
    <ws:FindID_request
    Find__CompIntfc__DL_TREE_IB_CI="{compID.text}"/>
    then I get:
    1067: Implicit coercion of a value of type String to an
    unrelated type com.draper:Find__CompIntfc__DL_TREE_IB_CITypeShape
    Can anyone help with this please?
    Thanks
    Jim

    Chris,
    Thanks. That is what I *was* doing, that got me all data
    returned. The parameter never gets passed in the XML. It acts as if
    a blank was passed and returns everything (just as you would expect
    in the PeopleSoft search page when you just click Find without
    specifying a key). It is expecting a partial key and will return
    all keys that match (find method).
    PS expects the key DL_CS_COMPID, and in Flex I've seen
    Find__CompIntfc__DL_TREE_IB_CI also. So I've tried:
    <mx:request>
    <!-- <DL_CS_COMPID> -->
    <Find__CompIntfc__DL_TREE_IB_CI>
    {compID.text}
    </Find__CompIntfc__DL_TREE_IB_CI>
    <!-- </DL_CS_COMPID> -->
    </mx:request>
    (You can see I currently have dl_cs_compid commented out).
    Both behave identically - they are ignored in the XML that is sent
    from Flex. Here is a sample of what was received in PS:
    <?xml version="1.0"?>
    <M540564.V1:Find__CompIntfc__DL_TREE_IB_CI
    xmlns:M540564.V1="
    http://xmlns.oracle.com/Enterprise/Tools/schemas/M540564.V1"
    xmlns:SOAP-ENV="
    http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"/>
    I believe there should be a
    <DL_CS_COMPID>value</DL_CS_COMPID> string in there.

  • Call native methods from windows dll

    Hello all,
    I want to call BlockInput method from User32.dll. My source code looks something like this:
    public class User32Dll_1 {
         static {
              try {
                   System.loadLibrary("User32");
              catch (Exception ex)
                   ex.printStackTrace();
         public static void main(String[] args) throws UnsatisfiedLinkError {
              BlockInput (true);
         /** @param b
         * @dll.import("USER32")*/
         private static native boolean BlockInput(boolean bBOOL);
    And the problem is that I get the following exception:
    java.lang.UnsatisfiedLinkError: BlockInput
         at User32Dll_1.BlockInput(Native Method)
         at User32Dll_1.main(User32Dll_1.java:27)
    Exception in thread "main"
    Can someone provide me a solution for this?
    Thank you in advance!

    can't do
    use JACOB
    http://danadler.com/jacob/
    or
    http://www.ezjcom.com/

  • Calling ABAP Code From BSP

    Hello all,
    I dont have much idea of BSP ans would like to have some inputs from you all.
    I would like to know that can I call ABAP transaction from BSP page ?
    I have got a set of column entries just as an ALV column on my BSP page and I would like to provide hotspot or double click functionality so that for each of the entries in the table , the BSP page navigates to ABAP tcode and back to BSP page.Is this functionality possible?
    any help would highly be appreciated.
    Regards
    Amruta

    Hi Amruta ,
    You can't call an R/3 transaction directly from BSP.
    But you can achieve all the functionalities it does .
    for ex ..if an r/3 transaction is a report , u hav to code in BSP editor .u can call function modules from BSP .
    But one thing u hav to concern is ,,in BSP Apllication logic is seperatd from Business logic .
    U hav to move all your results into an itab / params and display that inside HTML tables .
    Start ur journey from here .......
    http://help.sap.com/saphelp_erp2004/helpdata/en/e6/e23fd8c47e11d4ad320000e83539c3/frameset.htm
    All the best .
    Regards,
    J

  • GUI crashes when calling native code..

    Hi,
    I have interfaced to an existing C program using the Java Native Interface and I am controlling the C program using a GUI. The problem is that everytime I click on the button to call the native method, the GUI crashes... The bizarre thing is that the C code seems to actually execute properly and no exceptions are thrown..
    Anyone come across this problem?
    /john

    Hi,
    Thanks for the replies...
    The GUI completely disappears. No error file is generated. No exceptions are thrown. Here it is in more detail..
    The C code is invoked using the java native interface. The C code converts a MIDI file to a text file. It is normally run in DOS and accepts two parameters. You would run it in DOS normally as follows:
    mf2t Example1.mid Example1.txt.
    In the GUI I select the MIDI file and specify the output file (Example1.txt). I then pass these two parameters to the C code. The C code originally used argc and argv to accept the parameters. I replaced these with "fileArray" and "parameter"... "mf2t" replaces "main" in the native code...
    On the java side the code looks like this:
    static public native boolean mf2t(String s6, String s7);
    public String infile; // Input MIDI file
    public String textOut; // Output text file
    private void MIDIButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Object target=evt.getSource();
    if(target == MIDIButton) {
    if(mf2t(infile,textOut)){
    InfoLabel.setText("MIDI to text conversion complete");
    The code is built on the C side into a DLL using MS Visual Studio.
    On the C side the code looks something like this:
    static char *fileArray[5];
    static int argument=3;
    static char midiArray[25];
    static char txtArray[25];
    void mf2t(int argument,char * fileArray[]);
    // Entry point to native C code is here
    JNIEXPORT jboolean JNICALL
    Java_MainWindow_mf2t (JNIEnv *env, jobject j1, jstring midi, jstring txt)
    const jbyte *midiFile;
    const jbyte *txtFile;
    midiFile=(*env)->GetStringUTFChars(env,midi, NULL);
    txtFile=(*env)->GetStringUTFChars(env,txt, NULL);
    // The lines above just convert the java string into a C equivalent..
    strcpy(midiArray,midiFile);
    strcpy(txtArray,txtFile);
    fileArray[0]="mf2t.exe"; // Here I get fileArray to point to the converted strings
    fileArray[1]=midiArray;
    fileArray[2]=txtArray;
    mf2t(argument,fileArray); // Then I pass this to a native method
    (*env)->ReleaseStringUTFChars(env,midi, midiFile);
    (*env)->ReleaseStringUTFChars(env,txt, txtFile);
    return 1;
    void mf2t(int argument,char * fileArray[]){
    // native code in here
    I think it may have something to do with threads.. I'm not sure though.. It's impossible to know whats going on in the C code when the GUI crashes. If anything looks strange it's because I left out some code here for the sake of brevity... Still if you see anything that stands out let me know..
    Thanks,
    John

  • Calling c code from java

    hello everyone
    I have question
    I need to call c program from java
    I don't have problem with application or exe file in c it is working but when I call it from java it doesn't work there is no error but it doesn't work because when I execute the c program the black screen must be appeared so that I can enter the input file and then it produces the output file but in java I cann't see the black screen so please can you tell me the problem
    I have used the following code to call c from java:
    String line;  
                   String output1 = "";  
                         Process p = Runtime.getRuntime().exec("cpp.exe");  
                         BufferedReader input = new BufferedReader  
                               (new InputStreamReader(p.getInputStream()));  
                         while ((line = input.readLine()) != null) {  
                               output1 += (line + '\n');  
                         input.close();

    Hi,
    Try this in your code
    p.waitFor();It is for waiting of the process till the completion of the I/O.
    Regards

  • Opening a file in its native application from Flex.

    Is it possible to open a file on whatever native application the user runs it as?  Or even, at that, to simply open the directory it's in, in an explorer window?
    We have a search application and the frontend is in Flex, and I'm trying to find a way to do this, such that when a use double clicks on a result (in a datagrid - but that's trivial), it opens the file or at least the location of the file on the OS.
    Any system call where I can say system("explorer.exe " + filepath); or something?
    Any help would be appreciated.

    Dear BillBlalock ,
    thank you for answer!! You are very kind and helpful!! I would like to inform everybody that I have finally find another way of soilving my problem and I announce it to the forum in case somebody else encounters the same problem. Well, I soved the nproblem by using the following code:
        excelButton.addActionListener(new ActionListener()
           public void actionPerformed(ActionEvent e)
             String filePath = "\""+saveFileName.toString()+"\"";
             System.out.println(""+filePath);
             try
               String cmd="explorer "+filePath;
               Process p = Runtime.getRuntime().exec(cmd);
             }catch(IOException ec){}
         });I hope it can be useful to somebody!! By this code, I can make a button (in my case the excelButton) to open any file in its default application. Keep up the great work you are doing guys!!

  • How to call c++ code from java

    i have a third party dll written in c++. I want to call its methods in java. I searched web and found that I have to use JNI for this. I have seen examples on web writing c++ code and then using it from java through JNI, but can anybody please point to me the example where i have a predefined library or dll in c++ and i have to call it in java. I think that I may have to declare methods in library as native in java and then write a wrapper implementation (dll) in c++ which actually calls the library or dll functions. But, then how will I call methods of dll from my wrapper code.
    Any examples, please point
    Regards,
    Farooq

    There's a JNI forum here that may be a better place for this question; though given the general nature of the question, I suspect that they'll refer you to a tutorial. good luck.

  • 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

Maybe you are looking for

  • Log In Error for Particular User in FDM

    My manager had set up my ID to be able to log into FDM, but when I try to log in (using that ID which is the same as the one used for HFM), I receive an error message that says: Error: An error occurred logging on to the system Detail: Type mismatch

  • Photos show as duplicates

    How can I get into the icloud photo album, it appears it has duplicated all my photos.  My iphone and ipad now list all photos and videos twice, where and how can I go to clean that up?  Thanks

  • My mac keeps crashing and restarting.

    While i'm using iMovie and it's features, my mac crashes and restarts. This all started after I updates to Yosemite and the corresponding app updates. Any similar issues and successful troubleshooting methods? Its very frustrating.

  • Error in parked document

    While posting the parked document I am getting the error " No batch input data for screen SAPMZSERVTAX 2000" please help...

  • Deleting/itunes playlists

    i opened my itunes and someones limewire playlist showed up in my sidebar.iwould like to know how to get rid of it.i cant download it or delete it .