Create JVM from my own dll

Hi all,
I'm trying to create a JVM from within a windows dlln (vc++6) I'm writing. In the DllMain's DLL_PROCESS_ATTACH method of my dll I call a method called createJavaVM, this method creates the virtual machine.
Using that method in a simple console application works ok, but using it in my dll it hangs and seems to wait forever. If I use -verbose:jni it shows 5 similar lines, all about [Dynamic linking native method java.lang.... JNI].
I'm using jdk1.5.0_04.
Can someone help me with this problem?
TiA
Alexander

see here.    You will need the Pro version of LabVIEW or purchase tha application builder from NI
Paul <--Always Learning!!!
sense and simplicity.
Browse my sample VIs?

Similar Messages

  • Can't create JVM from JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);

    I'm new in using JNI. When i compile the C program that invoke the JAVA program, everthing goes fine. I can obtain the the "exe" from the compilation.
    But when i run the "exe" file it display "can't create Java VM". Here is the part of the code in C program:
    ........//other code
    JNI_VERSION_1_2
    JavaVMInitArgs vm_args;
    JavaVMOption options[1];
    options[0].optionString =
    "-Djava.class.path=" USER_CLASSPATH;
    vm_args.version = 0x00010002;
    vm_args.options = options;
    vm_args.nOptions = 1;
    vm_args.ignoreUnrecognized = JNI_TRUE;
    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    if (res < 0) {
    fprintf(stderr, "Can't create Java VM\n");
    exit(1);
    .......//other code
    I'm using JDK1.3, and windows ME.
    Can anyone tell me the problem?

    I think you need to get the address of the create function from the jvm.dll at runtime and call that: this works for me:
         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,"\\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();
         }

  • Using this program You can create animations from your own pictures (JPG, GIF, BMP, AVI, ICO, PNG) a

    It has object-oriented interface wich helps you edit pictures,work with content,anf use graphic distortion like shadows,transparenci as well as warp modification.
    make link from this topic to the following address:
    http://mateus.fastcomputertools.com/stores/mateus/95798pgabout.html

    It has object-oriented interface wich helps you edit pictures,work with content,anf use graphic distortion like shadows,transparenci as well as warp modification.
    make link from this topic to the following address:
    http://mateus.fastcomputertools.com/stores/mateus/95798pgabout.html

  • Why i cannot create the sql azure database from my own country 'Nepal' ?. why it is not include in the list of country when we sign up for azure database. :( !!!

    why i cannot create the sql azure database from my own country 'Nepal' ?. why it is not include in the list of country when we sign up for azure database. :(  !!!
    canot we try this new feature ,dosnot we need to try this too..why such discermination for our country nepal. :(

    Hi Anil,
    I am Mahesh from Microsoft Innovation Center. From August 2014 we have made Azure Available to Nepal. You can now directly sign in to azure with your Nepal Based Mobile Number as Verification.
    Thanks for showing your Interest in our Product.
    Mahesh Dahal

  • How can I edit material from 1 or more dvds that I created from my own filmed material in iMovie but which I no longer have in iMovie

    How can I edit material from 1 or more dvds that I created from my own filmed material in iMovie but which I no longer have in iMovie

    You need to 'reverse engineer' them :
    You need to convert the VOB files in the TS-Folder of the DVD back to DV which iMovie is designed to handle. For that you need mpegStreamclip:
    http://www.squared5.com/svideo/mpeg-streamclip-mac.html
    which is free, but you must also have the  Apple mpeg2 plugin :
    http://www.apple.com/quicktime/mpeg2/
    (unless you are running Lion in which case see below))
    which is a mere $20.
    Another possibility is to use DVDxDV:
    http://www.dvdxdv.com/NewFolderLookSite/Products/DVDxDV.overview.htm
    which costs $25.
    For the benefit of others who may read this thread:
    Obviously the foregoing only applies to DVDs you have made yourself, or other home-made DVDs that have been given to you. It will NOT work on copy-protected commercial DVDs, which in any case would be illegal.
    And from the TOU of these forums:
    Keep within the Law
    No material may be submitted that is intended to promote or commit an illegal act.
    Do not submit software or descriptions of processes that break or otherwise ‘work around’ digital rights management software or hardware. This includes conversations about ‘ripping’ DVDs or working around FairPlay software used on the iTunes Store.
    If you are running Lion:
    From the MPEG Streamclip homepage
    The installer of the MPEG-2 Playback Component may refuse to install the component in Lion. Apple states the component is unnecessary in Lion, however MPEG Streamclip still needs it.
    To install the component in Lion, please download MPEG Streamclip 1.9.3b7 beta above; inside the disk image you will find the Utility MPEG2 Component Lion: use it to install the MPEG-2 Playback Component in Lion. The original installer's disk image (QuickTimeMPEG2.dmg) is required.
    The current versions of MPEG Streamclip cannot take advantage of the built-in MPEG-2 functionality of Lion. For MPEG-2 files you still need to install the QuickTime MPEG-2 Playback Component, which is not preinstalled in Lion. You don't have to install QuickTime 7.

  • Can I Call method on one JVM from another through a dll?

    Let me explain.
    I have this java jar file that I can only have one instance of running at any given time. I'm using a shared data segment in a dll to store a bool indicating whether the program is already running or not. If it's already running, I have to not run the second instance and give focus to the current running instance.
    The jar file calls a native method "canInstantiate()" on a dll to see if there's already an app running. If there isn't, the env and obj are stored in the shared data segment of the dll and we return true. If there is already an instance of the program running, I want canInstantiate call a function on the current instance of the jar (like a callback) to tell it to request focus. It's not working. Can someone tell me if my code is right?
    The .h file
    #include "stdafx.h"
    #include <jni.h>
    #include "CardServer.h"
    #pragma data_seg("SHARED") // Begin the shared data segment.
    static volatile bool instanceExists = false;
    static JavaVM *theJavaVM = NULL;
    static JNIEnv* theJavaEnv= NULL;
    static jobject instanceObject = NULL;
    static jmethodID mid = NULL;
    static jclass cls = NULL;
    #pragma data_seg()
    #pragma comment(linker, "/section:SHARED,RWS")
    jdouble canInstantiate(JNIEnv *env, jobject obj);
    jdouble instantiate(JNIEnv *env, jobject obj);
    jdouble uninstantiate(JNIEnv *env, jobject obj);
    void grabFocus();
    </code>
    The .cpp file:
    <code>
    #include "MyFunctions.h"
    #include <string.h>
    #include <stdlib.h>
    #include "stdafx.h"
    #include <iostream.h>
    jdouble canInstantiate(JNIEnv *env, jobject obj)
    printf("In canInstantiate!!");
    if (!instanceExists)
    printf("No instance exists!!");
    return (jdouble)0.0;
    else
    printf("An instance already exists!!");
    grabFocus();
    return (jdouble)1.0;
    jdouble instantiate(JNIEnv *env, jobject obj)
    printf("**In CPP: Instantiate!!\n");
    cout << "At start, env is: " << env << endl;
    cout << "At start, obj is: " << obj << endl;
    if (instanceExists == false)
    instanceExists = true;
    theJavaEnv = env;
    instanceObject = obj;
    theJavaEnv->GetJavaVM(&theJavaVM);
    cls = (theJavaEnv)->FindClass("TheMainClassOfTheJar");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    printf("About to call grabFocusInJava\n");
    grabFocus();
    printf("CPP: After the grab focus command in instantiate!!\n");
    cout << "At end, env is: " << env << endl;
    cout << "At end, obj is: " << obj << endl;
    return 0.0;
    else
    printf("CPP: Finished Instantiate!!\n");
    return 1.0;
    jdouble uninstantiate(JNIEnv *env, jobject obj)
    printf("CPP: In uninstantiate!!\n");
    if (instanceExists == true)
    instanceExists = false;
    theJavaVM = NULL;
    instanceObject = NULL;
    printf("CPP: Finishing uninstantiate!!\n");
    return 0.0;
    else
    printf("CPP: Finishing uninstantiate!!\n");
    return 1.0;
    void grabFocus()
    printf("In CPP::GrabFocus!!\n");
    instanceObject = theJavaEnv->NewGlobalRef(instanceObject);
    cls = (theJavaEnv)->FindClass("CardFormatter");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    printf("Got the cls id again!!\n");
    if (cls == 0)
    printf("IT'S INVALID!!\n");
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    theJavaEnv->CallIntMethod(instanceObject, mid, 2);
    printf("Called grabFocusInJava\n");
    </code>
    thanks in advance

    Can I Call method on one JVM from another through a dll
    ...The rest of your question merely expands on your title.
    And the answer to that question is no.
    When you call a method you are executing a "thread of execution." A thread of execution exists only in a single process. It can not exist in another process.
    If the dll is doing some interesting things then you could call a method that sets a flag. Data can move between instances. But you would then have to have a thread in that different process monitoring that flag. And sharing data in a dll is not a normal process, so it would have to be coded appropriately.
    If all you want to do is set the current focus to the existing application, then that can be done with existing windows functionality. You don't need to do anything special in your dll. You can probably search these forums to find the exact code. If not there are countless examples in windows repositories (like MSDN) on how to do that.

  • What happened to the feature enabling me to create a signature from my own files?

    I have been able to sign my PDF forms from my own files now I cannot do this where or when did this feature disappear ??

    Some menu entries in the main menu bar are hidden if you use the mouse and only appear if you use the keyboard to open the menu (Bug 626825).
    You can see the difference if you use Alt+F to open the File menu or other menus like the Edit menu (Alt+E) and Bookmarks menu (Alt+B) and compare that to what you see if you use the mouse to open the menu after you have made the menu bar visible by tapping Alt or by pressing F10.
    * "Bookmark All Tabs" (Shift+Ctrl+D) no longer shows in the Bookmarks menu unless you open the Bookmarks menu via the keyboard (Alt + B).
    * "Bookmark All Tabs" can be accessed via the right-click context menu of a tab on the tab bar.
    See also:
    * https://support.mozilla.com/kb/how-do-i-use-bookmarks
    * Bookmark All: https://addons.mozilla.org/firefox/addon/bookmark-all/

  • Problem invoking JVM from Windows

    Hi all,
    I tried to create a JVM instance as laid out in the examples. The JVM is never getting created. I am using Visual C++ (I need to, when the code works I will be creating a DLL that is an addon to someother piece of software).
    I have posted the code below::
    #include "stdafx.h"
    #include "invoke2.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    // The one and only application object
    CWinApp theApp;
    using namespace std;
    int main(void)
         int nRetCode = 0;
         // initialize MFC and print and error on failure
         if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
              // TODO: change error code to suit your needs
              cerr << _T("Fatal Error: MFC initialization failed") << endl;
              nRetCode = 1;
         else
              JNIEnv *env;               /* The java vm environment                                        */
              JavaVM *jvm;               /* The actual jvm                                                  */
              CString fname;               /* The file name of the generated intermediate obj file */
              JDK1_1InitArgs vm_args;
              jint res;
              jint vmavail;
              jclass cls;
              jmethodID mid;
              //char classpath[4096];
              bool viewerready;          /* is this java viewer valid?                                   */
              vm_args.classpath=".";
              vm_args.version = JNI_VERSION_1_4;
              vmavail=JNI_GetDefaultJavaVMInitArgs(&vm_args);
              if(vmavail < 0)
                   AfxMessageBox(" That VM version is not available. ",100,100);
                   viewerready=false;
                   jvm=NULL;
                   env=NULL;
              else
                   vm_args.classpath=".";
                   res = JNI_CreateJavaVM(&jvm,(void **) &env,&vm_args);
                   if(res < 0)
                        AfxMessageBox("Could not create JVM instance. \n Check your classpath. \n 3D viewer will not be available. ",100,100);
                        jvm=NULL;
                        env=NULL;
                        viewerready=false;
                   else
                        cls = env->FindClass("OBJViewer");
                        if(cls == 0)
                             AfxMessageBox("Can't find the java OBJViewer class. ",100,100);
                             viewerready=false;
                        mid = env->GetMethodID(cls, "OBJViewer", "");
                        if(mid == 0)
                             AfxMessageBox(" java class OBJViewer has no constructor OBJViewer() ");
                             viewerready=false;
                        env->CallStaticVoidMethod(cls, mid);
         return nRetCode;
    }

    Hey guys :)
    I incorporated the changes suggested by David and "reberst" and then did the stuff told by "LathaDhamo".
    Now I am able to invoke the VM without problems and my test program runs and displays windows and takes in input etc.. Thank you, Thank you, Thank you!!
    But now, I noticed that all this happens only when I am in debug mode in VC++ and step thru the program. When my external program loads the DLL I created automatically, I get the error message that the "JavaTest" class was not found. This will lead to errors when I deploy the DLL or package it for others. How do I ensure that the class is always found? What do I have to do?
    I am sorry for being so amtuerish and asking so many questions. This is my first time using JNI from the native side.
    Thank you,
    vijai.
    JavaOBJViewer::JavaOBJViewer(void)
         memset(&args, 0, sizeof(args));
         args.version = JNI_VERSION_1_4;
         args.nOptions = 2;
         options[0].optionString = "-Djava.class.path=.";
         options[1].optionString = "-Djava.library.path=.";
         args.options = options;
         args.ignoreUnrecognized = JNI_TRUE;
         res=JNI_CreateJavaVM(&jvm, (void **)&env, &args);
         if(res < 0)
              AfxMessageBox(" The JavaVM could not be initialized. \n Refer to the documentation on environment variable settings. \n 3D Viewer will not be available while modeling. ");
              jvm=NULL;
              env=NULL;
              viewerready=false;
         else
              cls = env->FindClass("JavaTest");
              if(cls == NULL)
                   AfxMessageBox("Can't find the java JavaTest class. \n 3D viewer will not be available while modeling. ",100,100);
                   viewerready=false;
              else
                  mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
                   if(mid == NULL)
                        AfxMessageBox(" java class JavaTest has no main method. ");
                        viewerready=false;
                   else
                        tempf = env->NewStringUTF("testenvp.obj");
                        logf = env->NewStringUTF("java_viewer_log.txt");
                        if((tempf == NULL) || (logf == NULL))
                             AfxMessageBox("The Java VM had insufficient memory to create the argument array. ",100,100);
                        else
                             mainargs = env->NewObjectArray(2,env->FindClass("java/lang/String"), logf);
                             if(mainargs == NULL)
                                  AfxMessageBox("The Java VM had insufficient memory to create the argument array. ",100,100);
                             else
                                  env->SetObjectArrayElement(mainargs,2,tempf);
                                  env->CallStaticVoidMethod(cls,mid,mainargs);
                                  jthrowable exc;
                                  exc = env->ExceptionOccurred();
                                  if(exc)
                                       AfxMessageBox(" An unknown exception occurred. ",100,100);
                                       viewerready=false;
                                  else
                                       viewerready=true;
    }

  • Launching a 64 bit jvm from a 32 bit jvm

    I want to launch a 64 bit jvm from a 32 bit jvm. The current application works like this
    1) The parent jvm A allows users to launch a child jvm B. Child jvm B inherits A's libraries (LD_LIBRARY_PATH) and also A's classpath entries.
    2) User can specify his/her own libraries that are to be passed to B (child jvm). These entries are prepended to the inherited entries (A.LD_LIBRARY_PATH).
    3) User can specify his/her own classpath entries that are to be added to B. These entries are appended to the inherited entries (A.classapth).
    The whole idea behind making the child jvm configurable is that the user can specify a suitable jvm for the child. But optionally the user might specify a different java home (pointing to a 64bit jre/jdk).
    Questions :
    1) Would simply changing the java for the child suffice? That is instead of
    java -classpath=<inherited-entries:specified-entries> abc
    we do
    -user-specified-java -classpath=<inherited-entries:specified-entries> abc
    I have seen that the jvm uses the java.home from the java provided while launching the jvm. Example
    $java -version
    1.5
    $java abc
    // will use default java's home as java home internally
    $/usr/lib/java-64/jdk/bin/java -version
    1.5 64bit
    $/usr/lib/java-64/jdk/binjava abc
    // will use /usr/lib/java-64/jdk as java home internally
    2) How will the classpath entries and libraries interact/interfere with the newly spawned jvm?
    Here if the user specifies new libraries for 64 bit jvm, how will they interact/interfere with the 32bit libs.
    3) What about native(esp jni) libraries?
    Bigger picture :
    If A is running sun java jdk1.5_a (32bit) and user can specify B as
    1) sun jdk 1.x_y (32bit) such that x_y != 5_a
    2) sun jdk 64 bit
    3) any other 32 bit java implementation (ibm, jrocket ...)
    4) any other 64 bit java implementation (ibm, jrocket ...)

    jschell wrote:
    Questions :
    1) Would simply changing the java for the child suffice? That is instead of
    java -classpath=<inherited-entries:specified-entries> abc
    we do
    -user-specified-java -classpath=<inherited-entries:specified-entries> abc
    You cannot do it without creating a new process.
    ProcessBuilder/Runtime.exec() create a new process. The new process can do anything.
    You can set the environment using either.
    Yes. The process B will be spawned either using ProcessBuilder or using Runtime. The question still remains,
    Q: If I have a classpath defined already for a particular java implementation and the LD_LIBRARY path is all set, what will be effect of changing the default java.
    Example :
    If my classpath and LD_LIBRARY_PATH is set to use/work-with /usr/lib/javaA/ then
    "/usr/lib/javaA/jre/bin/java -classpath $classpath abc" will work smoothly
    But what will happen if I do classpath=$classpath:$new-javaB-classpath-entries and LD_LIBRARY_PATH=$LD_LIBRARY_PATH_FOR_B:$LD_LIBRARY_PATH and
    "/usr/lib/javaB/jre/bin/java -classpath $classpath abc"
    >
    2) How will the classpath entries and libraries interact/interfere with the newly spawned jvm?
    Here if the user specifies new libraries for 64 bit jvm, how will they interact/interfere with the 32bit libs.
    3) What about native(esp jni) libraries?
    New process = new environment.
    If there is a problem it is because of how you set it up or how they are used in the first place.I am more interested in the if. My question is can it happen and if yes whats the explanation and how to solve it.
    >
    As an example if an app needs a 64 bit library and there is only a 32 bit library then what happens depends entirely on the app that needs the 64 bit library. That question would be the same if you attempted to run the application from a console window.So here is another way of looking at it. Imagine you want to kick off a 64 bit java app from your console. Assume that you can only prepend to classpath. Also you can append to LD path. Now you have provided all that is needed for the app to run. But under the classpath constraints, what will be the behaviour?

  • Can not select from my own MV. Please help.

    Hello Gurus,
    I have created a MV with following clauses
    CREATE or REPLACE MATERIALIZED VIEW "OWNER_NAME1"."MV_Name1"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH COMPLETE
    AS
    SELECT column1, column2 .... from table1,table2
    where .....
    I have logged in to DB with the 'owner_name1' schema itself which is the owner of the MV.
    But, when I try to select from the above MV. It gives error "Ora-00942 table or view does not exist"
    I can see the same under 'user_objects' view as an object of owner_name1 schema.
    Could you please help me in understanding where I have gone wrong?
    DB - Oracle 9i on unix platform.
    Thanks in advance!
    Abhijit.

    Oh! I missed to mention the exact steps followed by me which created error for me,
    viz.
    1) I have 2 Database and their users as follows
    bq. i) DB1 in local server - 'localUser'
    bq. ii) DB2 in remote server - 'RemoteUser1' and 'RemoteUser2'
    2) 'RemoteUser2' user in DB2 has 'select' privilage on table 'RemoteTable1' of 'RemoteUser1' ( both are remote DB's users ! )
    i.e. select * from RemoteUser1.RemoteTable1; --works okay when logged into RemoteUser2. no synonyms are created hence using schema_name.table_name convention.
    3) Logged in to 'localUser' in DB1.
    4) Created a DB link 'local_to_remote2' in 'localUser' schema ( in DB1) to 'RemoteUser2' schema (in DB2)
    i.e.
    create database link local_to_remote2 connect to RemoteUser2 identified by password using 'connection_string';
    DBLink was created successfully.
    5) I could select from the tables of 'RemoteUser2' using DB Link. (by logging in to 'localUser')
    i.e. select * from RemoteUser1.RemoteTable1@local_to_remote2 ; --- gives me expected output. no issues!
    6) Now, I created below MV in 'localUser' ( no need to tell in 'DB1' )
    the exact syntax I used is as follows,
    CREATE or REPLACE MATERIALIZED VIEW "localUser"."MV_Name1"
    BUILD IMMEDIATE
    USING INDEX
    REFRESH COMPLETE
    AS
    SELECT column1, column2
    From RemoteUser1.RemoteTable1@local_to_remote2
    where condition1
    and condition2;
    The MV was created successfully, and I could see it as an 'Valid' object of 'localUser' schema.
    i.e. select * from user_objects where object_name ='MV_NAME1' and status ='VALID' --- tells that above create MV is an object of owner 'localUser'
    But, when I try to select from the said MV. it gives me error "Ora-00942 table or view does not exist"
    i.e. select * from MV_Name1; ---- neither this
    select * from localUser.MV_Name1; ---- nor this works :(
    Even when I try to drop the same MV it gives me same error. :(
    Could you please suggest me anything so that I will be able to select from MY OWN MV ?
    Please help Gurus.

  • CREATE SEQUENCE from a stored procedure

    Hello,
    Is it possible, to create a sequence object from an own written stored procedure? Can I reinitialize the actual value of a sequence object without recreating it from a stored procedure?
    Thank you for recommendations,
    Matthias Schoelzel
    EDV Studio ALINA GmbH
    Bad Oeynhausen

    maybe this example might be of some help.
    SQL> create or replace procedure dy_sequence (pSeqName varchar2,
      2                                           pStart number,
      3                                           pIncrement number) as
      4    vCnt     number := 0;
      5  begin
      6    select count(*) into vCnt
      7      from all_sequences
      8     where sequence_name = upper(pSeqName);
      9 
    10    if vCnt = 0 then
    11      execute immediate 'create sequence '||pSeqName||
    12                        ' start with '||to_char(pStart)||
    13                        ' increment by '||to_char(pIncrement);
    14    else
    15      execute immediate 'alter sequence '||pSeqName||' increment by '||to_char(pIncrement);
    16    end if;
    17  end;
    18  /
    Procedure created.
    SQL> -- create the sequence by calling the dy_sequence procedure
    SQL> execute dy_sequence ('test_sequence',1,1);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             1
    SQL> -- alter the sequence to increment by 2
    SQL> execute dy_sequence ('test_sequence',0,2);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             3
    SQL>

  • EvaluatingTteststand 4.2.1: Null pointer access violation (error 17502) when attempting to use a mixed-mode std::map / boost shared_ptr class contained in a DLL through an interface from a different DLL

    Hi there.
    I have been working on a test system which will potentially have TestStand at its core, and downloaded/installed the 4.2.1 evaluation. Current details from the information dialog are:
    TestStand Engine version 4.2.1 (4.2.1.83)
    Sequence Editor Verison 4.2.1.83
    The system will drive mobile radio devices using RS232 serial interfaces, usnig a variety of serial protocols (Hayes, and a couple of proprietary binary protocols for other work).
    We already have in existence a soak tester, written in VS2005 with MFC unmanaged DLLs and also managed DLLs, which are mixed up together to provide different aspects of the functionality required for the binary protocols.
    I have created:
    1. a "master wrapper" DLL for the constellation of other DLLs - this offers up a simple C-API interface which I hope TestStand will use. It's called "SerialSessionMgr.dll""
    2. a mixed managed / unmanaged "IJW" (it just works) DLL which wraps up the binary logging protocol control interfaces, which are entirely in managed C++/CLI: the "master wrapper" DLL calls into this through an unmanaged interface to create instances of the CLI-compiled class which interfaces to the underlying managed DLLs imlpementing the logging protocol. This is called "WinTseInterface.dll".
    Before I started evaluating TestStand, I knocked up a test harness using CPPUnit / MFC, with which I was able to test SerialSessionMgr.dll and its' use of WinTseInterface.dll and verify they worked. The harness loads the DLL dynamically at run-time using AfxLoadLibrary() to try to emulate the way TestStand uses it.
    When we open a
    TSE session:
    The SerialSessionManager makes a call to the
    WinTseInterface.dll to "create" a logging instance. The instance is
    created in a std::map which is held by the CWinApp derived class, this map
    contains boost::shared_ptr of the class which works with a managed class. So we
    have a call trace: Client
    app->SerialSessionManager{TseStartSession()}->WinTseInterface{WINTSE_GetWinTseBridge()} - WINTSE_GetWinTseBridge()
    just creates a new instance of the unmanaged class which interfaces through to
    the managed CLI/C++ class beneath, and returns the address to the
    SerialSessionManager, which stores it.
    The SerialSessioManager actually initialises the WinTseBridge using a method of a C++ pure virtual interface class to the class in the std::map in the WinTseInterface DLL
    implements. The initialise call passes miscellaneous details and actually calls
    "gcnew" to create the managed class which interfaces to the
    underlying managed DLLs which implement the logging protocol.
    My logs of the DLL loading as seen in VS2005 debug output are attached this message as PDFs
    While trying to fix this, I have tried:
    Enhancing the WinTseInterface DLL so it manually loads all the other assemblies in the logging system, including the managed portion of WinTseInterface itself (no effect)
    All the different options for the way the C DLL adapter loads and unloads the DLL in the DLL adapter steptype in TestStand
    I've even tried calling directly into the WinTseInterface DLL before trying any SerialSessionManager DLL calls to try to load the WinTseInterface DLL completely beforehand
    and I cannot stop this exception.
    It seems like the object is created in the WinTseInterface DLL OK (I have debugged the creation step which runs for WINTSE_GetWinTseBridge() and the object is created OK) when the SerialSessionManager makes the call, but when it calls the first managed function, which creates the managed object, the DLL is reloaded as managed - I suspect this causes the object to be destroyed or overwritten, and thus the call to initialise bombs with null pointer violation.
    Have I done something obviously wrong, and what other approaches can I take? 
    Does TestStand 4.2.1 have issues with driving DLLs which use managed/unmanaged DLLs beneath them?
    My nuclear option is to throw the WinTseInterface DLL out completely and wrap up the managed C++ CLI code in a new interface, entirely managed, and use the TestStand ".Net" adaptor to drive that, creating my step library to run to that directly. This isn't ideal as I have some co-ordination of the protocols which is implemented in the SerialSessionMgr DLL.
    I hope someone can help. This one's low level, dirty and a stumper to me.
    Many thanks to the NI community. This is my first posting!
    Solved!
    Go to Solution.
    Attachments:
    CPPUnit Test Harness DLL load debug output.pdf ‏18 KB
    TestStand DLL load & crash debug output.pdf ‏43 KB

    Hi there Ray.
    First - many thanks for engaging with this thorny problem. Love the avatar BTW.
    I've been using the C/C++ DLL adapter: the original premise of the Serial Session Manager DLL was to provide a simple C type functional interface, using simple data types, so that TestStand would be able to drive the underlying functionality easily through a single DLL.
    Seeing as you've been kind enough to respond, I should explain the makeup of the DLLs a little more, I think.
    The SerialSessionManager (SSMgr) DLL uses C++ and MFC internally. This is the DLL which TestStand calls into directly through the C/C++ adapter. This DLL does have one odd feature though - because the it uses the Windows Multimedia Timer (implemented in WinMM.dll) I had to artificially create a scenario where it would load the .Net mscoree DLL _before_ it loads WinMM.dll - (http://connect.microsoft.com/VisualStudio/feedback/details/329819/freelibrary-in-the-winmm-dlls-modu...), basically WinMM.dll's init code gets rather upset when .Net DLLs load, which causes the entire executable to be unloaded with subsequent crashes.
    To work around this crash, the SSMgr has a single, completely empty, file which is compiled for CLR, effectively forcing a dependency into the DLL on the .Net subsystems and turning the DLL into a "IJW" binary. The resulting DLL doesn't actually have any executable managed .Net assemblies, but I'm guessing that it does contain enough .Net related stubs and information that when the DLL is loaded, mscoree.dll loads before WinMM.dll - and this means the system doesn't crash.
    Now, on to the WinTseInterface DLL. My initial description of this little software system was done in something of a hurry.
    This DLL is the C++/CLI "IJW" DLL which actually contains managed and unmanaged code. Underneath the WinTseInterface DLL is another system of (this time exclusively C++/CLI) DLL assemblies which implement the TSE protocol interpretation system.
    When the SSMgr DLL needs to start a TSE protocol session, it calls a C-API function in the WinTseInterface which creates a new CWinTseBridge class. Here's the steps in a little more detail:
    SSMgr DLL calls WINTSE_GetWinTseBridge(), passing in the name of the device which needs it (this is used to put the new WinTseBridge into a std::map in the WinTseInterface DLL) - this call runs just fine, and returns the address of the CWinTseBridge C++ object. This is stored in the SSMgr, because the CWinTseBridge class implements a pure virtual interface which is used by the SSMgr as a way of accessing the CWinTseBridge methods. 
    We now use the address from (1) to make a call to CWinTseBridge::Initialise(), passing some basic configuration details.
    I've run VS2005 debug on the Sequence Editor when running the test, and done F11 step-throughs of the code loading each parameter in the Initialise() call onto the stack, and what appears to happen is that when the call is made, the whole lot steps off into oblivion (a reference to 0x00000000 is made, I think).
    Do you think it's worth trying to get this approach to work? It would be useful to retain the control surface in the top of the SSMgr as there is co-ordination of the protocols within the logic of that component. If I move the Wintse control out into a separate managed DLL I may not have that co-ordination (this might be overcome with some design, as I've confirmed that it is possible to "reach into" the WinTseInterface DLL with TestStand and create and use managed objects from assemblies contained within).
    Are there any known issues with this version of TestStand using C/C++ CLI IJW DLLs? I haven't found much out there on the web.
    Attachments:
    Tse_Test.seq ‏7 KB

  • Error on running JVM from a C program

    Hello there!!
    I'm using Open Watcom as a C compiler on Windows XP. I'm trying to run a JVM from a C program.
    I have specified the following as a library file :
    C:\Java\jdk1.5.0_04\lib\jvm.lib
    The code compiles very well, but I'm getting an error when running it.
    Windows tells me the following :
    "The entry point of the function ??_7VM_GetCurrentLocation@@6B@ can't be found in jvm.dll dynamic linking library"
    The code I've been trying to run is the following one :
    #include <jni.h>
    #include <stdio.h>
    #include <stdlib.h>
    void main()
    JavaVMOption options[3];
    JavaVMInitArgs vm_args;
    JavaVM *jvm;
    JNIEnv *jenv;
    long result;
    jmethodID mid;
    jfieldID fid;
    jobject jobj;
    jclass cls;
    int asize;
    printf("coucou\n");
    getchar();
    options[0].optionString = ".";
    options[1].optionString = "-Djava.compiler=NONE";
    options[2].optionString = "-verbose:jni";
    vm_args.version = JNI_VERSION_1_2;
    vm_args.options = options;
    vm_args.nOptions = 3;
    vm_args.ignoreUnrecognized = JNI_FALSE;
    JNI_GetDefaultJavaVMInitArgs(&vm_args);
    result = JNI_CreateJavaVM(&jvm,(void **)&jenv, &vm_args);
    /* if(result == JNI_ERR )
    printf("Error invoking the JVM");
    exit (-1);
    cls = (*jenv)->FindClass(jenv,"C:\Formation\Joly\FromCtoJava\WATCOM\samples\ide\win32\FromCtoJava");
    /* if( cls == NULL )
    printf("can't find class FromCtoJava\n");
    exit (-1);
    (*jenv)->ExceptionClear(jenv);
    mid=(*jenv)->GetMethodID(jenv, cls, "<init>", "()V");
    jobj=(*jenv)->NewObject(jenv, cls, mid);
    fid=(*jenv)->GetFieldID(jenv, cls, "arraySize", "I");
    asize=(*jenv)->GetIntField(jenv, jobj, fid);
    printf("size of array is %d",asize);
    (*jvm)->DestroyJavaVM(jvm);*/
    Cheers
    Joly

    I already did PATH.
    Open a console window.
    Explicitly set PATH to point ONLY to the appropriate java directory (where the dll is and executable) using something like the following
    set PATH=C:\xxx\yyy
    Then run your app again in the console window - no where else.

  • Cannot create mysites from powershell: Original XSLT List View Web Part not found

    I have a bizarre problem in my SharePoint 2013 farm. This does not occur in my test farm, only in the farm we were going to go live with.
    I'm on windows Server 2012, SQLServer 2012 SP1, SharePoint 2013 April CU. 1 appserver/centraladmin server, 2 web servers.
    When I log into our mysitehost and click newsfeed, it will create a mysite (even though first it displays "we are sorry there was a problem creating your site")
    But from powershell, whether I use $UserProfile.CreatePersonalSite() or New-SPSite, I get the following error:
    Original XSLT List View Web Part not found
    So far I've only found one other person with this:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2503e42c-e114-4e89-8e00-89fe70f0b154/cannot-create-sharepoint-mysite-programmatically
    This is a brand new farm, created with the same scripts I created my test farm with, and same version of SharePoint. Only the service accounts are different. (Farm account has admin on the servers right now since I was setting up profile service).
    Some other errors from the same correlation ID that look related:
    It can't seem to find the listemplate 101
    And something looks wrong with the MySiteDocumentLibrary feature
    I have tried the following:
    1. run psconfig.exe on each server
    2. install-spfeature -AllExistingFeatures
    3. looped through the directory under Features and for each called Install-SPFeature $dirname -Force
    4. uninstalled and reinstalled MySiteDocumentLibrary feature
    5. blew away the whole farm (removed all servers from farm, deleted all databases) and recreated it.
    6. tried creating the UPA from the CentralAdmin gui.
    The only real difference I can think of between the working farm and non working farm is, I installed the working farm using RTM, then as they came out added the March PU and April CU. For this farm I installed RTM and March and April, and then ran my build
    farm script.
    I am at a loss. What do I need to do, re-install the binaries? That's all I can think of. What I love is that our test / POC system worked fine, and now 2 weeks before go-live I'm seeing errors on the production servers I've never seen before. Using the
    same scripts no less.
    Feature Activation: Feature 'Fields' (ID: 'ca7bd552-10b1-4563-85b9-5ed1d39c962a') was activated
    Feature Activation: Feature 'CTypes' (ID: '695b6570-a48b-4a8e-8ea5-26ea7fc1d162') was activated
    No document templates uploaded for list "$Resources:core,global_onet_solutiongallery_list;" -- none found for list template "100"
    Failed to find <ListTemplate> tag corresponding to ID "101", tried both onet.xml for site definition ID "0" language "1033" and global site definition. Operation failed.
    No document templates uploaded for list "$Resources:core,stylelibraryList;" -- none found for list template "121".
    System.Runtime.InteropServices.COMException: A user may not remove his or her own account from a site collection.<nativehr>0x81020051</nativehr><nativestack></nativestack>, StackTrace: at Microsoft.SharePoint.SPUserCollection.UpdateMembers
    Feature Activation: Feature 'MySitePersonalSite' (ID: 'f661430e-c155-438e-a7c6-c68648f1b119') was activated
    Feature Activation: Activating Feature 'MySiteDocumentLibrary'
    Calling 'FeatureActivated' method of SPFeatureReceiver for Feature 'MySiteDocumentLibrary'
    SharePoint Foundation Upgrade MySiteDocumentLibraryFeatureReceiveraj08n INFO Creating new My Documents library
    Unknown SPRequest error occurred. More information: 0x80070002
    SPRequest.GetMetadataForUrl: UserPrincipalName=, AppPrincipalName= ,bstrUrl=http://contoso/personal/cbuchholz/DOCUMENTS ,METADATAFLAGS=59
    System.IO.FileNotFoundException: <nativehr>0x80070002</nativehr><nativestack></nativestack>, StackTrace: at Microsoft.SharePoint.SPWeb.GetObjectForUrl at Microsoft.SharePoint.Portal.UserProfiles.MySiteDocumentLibraryUtil.GetSPObjectFromUrl ...
    <nativehr>0x80070002</nativehr><nativestack></nativestack>There is no Web named "/personal/cbuchholz/DOCUMENTS"
    Possible mismatch between the reported error with code = 0x81070504 and message: "There is no Web named "/personal/cbuchholz/DOCUMENTS"." and the returned error with code 0x80070002.
    Attemping to add webpart id 0F6072F2-E804-4CFD-837E-BB37332B9D1C to web http://contoso/personal/cbuchholz
    Adding XsltListViewWebPart calling SPRequest::CreateListViewPart. Web part id 0F6072F2-E804-4CFD-837E-BB37332B9D1C, web http://contoso/personal/cbuchholz
    Feature receiver assembly 'Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c', class 'Microsoft.SharePoint.Portal.UserProfiles.MySiteDocumentLibraryFeatureReceiver', method 'FeatureActivated' for feature 'e9c0ff81-d821-4771-8b4c-246aa7e5e9eb' threw an exception: System.InvalidOperationException: Original XSLT List View Web Part not found at Microsoft.SharePoint.Portal.UserProfiles.MySiteDocumentLibraryUtil.ReplaceListViewWebPart
    Feature Activation: Threw an exception, attempting to roll back. Feature 'MySiteDocumentLibrary'
    Exception in EnsureFeaturesActivatedAtSite: System.InvalidOperationException: Original XSLT List View Web Part not found
    Failed to activate site-collection-scoped features for template 'SPSPERS#2' in site collection 'http://contoso/personal/cbuchholz'
    Failed to apply template "SPSPERS#2" to web at URL "http://contoso/personal/cbuchholz
    I've had other problems in this farm: the bug where when you add Administrators to a Search Service via the Manage Service Applications page, it removes the SPSearchDBAdmin role from the search service process account. That one did not happen in the other farm.
    At least other people have that one and I could just use the farm admin instead (still troublng of course).

    Ok,
    Here is the problem:
    When creating a mysite from powershell or script, apparently you can ONLY do this from a wfe (or a server running Microsoft SharePoint Foundation Web Application in services on server).
    You CANNOT create mysites from script on your appserver if it is not also a Web Application Server. I confirmed the same is true in my test farm. I guess I was always running most of these scripts on the webserver.
    I searched all over and cannot find this documented anywhere.
    Who do I contact to have Microsoft document this?
    It's Thursday morning, I've been working non stop since Saturday morning so you don't have to :)

  • Automator: Create folder from suffix of filename and put file names with same suffix into folder

    I've been using a script to use automator to create a folder from the filename and put that file into it the folder just created.
    I have a bunch of files that have similar names to them, but I don't want every file to be put into its own folder, instead I want all files with the same suffix (001) to go into the same folder.  I would also like the folder name to just be named the same as the suffix (001) instead of the full file name.
    For example all of these files names that end with the same integer (001) should be dumped into the same folder named "001":
    Boston_ProRes422_1920x1080_24p_Audio_001
    Boston_ProRes422_3840x2160_24p_Audio_001
    Boston_ProRes422_3840x2160_24p_RAW_Audio_001
    Boston_ProRes422_1920x1080_24p_Audio_002
    Boston_ProRes422_1920x1080_24p_Audio_005
    Boston_ProRes422_1920x1080_24p_Audio_010
    Any help at all would be incredible!!
    Thanks!
    Here's the script I'm using right now:
    on run {input, parameters} -- create folders from file names and move
      set output to {} -- this will be a list of the moved files
      repeat with anItem in the input -- step through each item in the input
      set {theContainer, theName, theExtension} to (getTheNames from anItem)
      try
      set destination to (makeNewFolder for theName at theContainer)
      tell application "Finder"
      move anItem to destination
      set the end of the output to the result as alias -- success
      end tell
      on error errorMessage -- duplicate name, permissions, etc
      log errorMessage
      # handle errors if desired - just skip for now
      end try
      end repeat
      return the output -- pass on the results to following actions
    end run
    to getTheNames from someItem -- get a container, name, and extension from a file item
      tell application "System Events" to tell disk item (someItem as text)
      set theContainer to the path of the container
      set {theName, theExtension} to {name, name extension}
      end tell
      if theExtension is not "" then
      set theName to text 1 thru -((count theExtension) + 2) of theName -- just the name part
      set theExtension to "." & theExtension
      end if
      return {theContainer, theName, theExtension}
    end getTheNames
    to makeNewFolder for theChild at theParent -- make a new child folder at the parent location if it doesn't already exist
      set theParent to theParent as text
      if theParent begins with "/" then set theParent to theParent as POSIX file as text
      try
      return (theParent & theChild) as alias
      on error errorMessage -- no folder
      log errorMessage
      tell application "Finder" to make new folder at theParent with properties {name:theChild}
      return the result as alias
      end try
    end makeNewFolder

    Thanks Neil for the response! That script didn't work, but I did get it to work with my old script by changing "set TheName to" numbers different.  Here's my final script which creates folders named "001", "002", and so forth and dumps in the files that end in that same suffix in the matching folder.
    on run {input, parameters} -- create folders from file names and move
      set output to {} -- this will be a list of the moved files
      repeat with anItem in the input -- step through each item in the input
      set {theContainer, theName, theExtension} to (getTheNames from anItem)
      try
      set destination to (makeNewFolder for theName at theContainer)
      tell application "Finder"
      move anItem to destination
      set the end of the output to the result as alias -- success
      end tell
      on error errorMessage -- duplicate name, permissions, etc
      log errorMessage
      # handle errors if desired - just skip for now
      end try
      end repeat
      return the output -- pass on the results to following actions
    end run
    to getTheNames from someItem -- get a container, name, and extension from a file item
      tell application "System Events" to tell disk item (someItem as text)
      set theContainer to the path of the container
      set {theName, theExtension} to {name, name extension}
      end tell
      if theExtension is not "" then
      set theName to text -5 thru -((count theExtension) + 4) of theName -- just the name part
      set theExtension to "." & theExtension
      end if
      return {theContainer, theName, theExtension}
    end getTheNames
    to makeNewFolder for theChild at theParent -- make a new child folder at the parent location if it doesn't already exist
      set theParent to theParent as text
      if theParent begins with "/" then set theParent to theParent as POSIX file as text
      try
      return (theParent & theChild) as alias
      on error errorMessage -- no folder
      log errorMessage
      tell application "Finder" to make new folder at theParent with properties {name:theChild}
      return the result as alias
      end try
    end makeNewFolder

Maybe you are looking for

  • Error Box displays in JClient Form with no text (preview 9.0.3)

    I am using Preview 9.0.3, with a JClient Form, running as an applet. When I execute the applet within JDeveloper, an Error box displays, but has NO text. When I try to close the box, it just keeps redisplaying, with no text. I am using the -Djbo.debu

  • Countless .png files after converting pdf to dwg

    After converting a .pdf file to a .dwg file using the export feature in adobe illustrator, I find that as many as 500 .png files come with the newly made .dwg after the conversion is complete. My question is, why do all these pictures come with the .

  • Problem with enabling thai language in forms

    Hi all, I am using forms6i, oracle10g db(client/server environment), NLS_LANG is:thai_thailand.th8tisascii, our font standard is:ARIAL when i give an i/p via forms the typed value is showing as junk characters.if i change the font for the particular

  • Update Invoice  - AR_TRANSACTION_PUB.update_transaction()

    Hi, I have requirement to update an invoice transaction. When I try to do so using ar_transaction_pub it is erroring out saying 'wrong number or types of types of arguments in call....'. I would appreciate if anyone could send me a sample code for ca

  • Ipod and the mini

    do these use different versions of itunes. I just got a new 30gb video ipod and I still have my mini, will i be able to use them both on the same computer and itunes? or will i need to put itunes on my computer twice or what. or is there any better s