How to Dynamically Load jvm.dll without setting PATH

Please help, invoking CreateJavaVM via a function pointer is returning -3, but I'm not sure why.
When my PATH is setup up to include the jvm.dll and I invoke JNI_CreateJavaVM() directly, it works fine. But I want it to work regardless of my PATH setting, so I am trying to use LoadLibrary and dynamically load the jvm.dll and then a function pointer to invoke CreateJavaVM().
The LoadLibrary returns non-NULL result, the GetProcAccress() returns non-null, but when I invoke the pointer to the CreateJavaVM call, it returns -3. I know -3 is JNI_EVERSION error, but any ideas what is wrong with the code below, such that it would give me this error?
Currently my code is as follows:
typedef jint (JNICALL CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
JavaVM *m_jvm;
JNIEnv *m_env;
SetDllDirectory(L"C:\\Program Files\\Java\\jdk1.6.0_20\\jre\\bin\\client");
HINSTANCE hVM = LoadLibrary(L"jvm.dll");
if ( hVM == NULL ) {
   // report error
CreateJavaVM_t *pfnCreateJavaVM = (CreateJavaVM_t*)GetProcAddress(hVM, "JNI_CreateJavaVM");
#ifdef JNI_VERSION_1_6
char cpChars[1024] = {0};
sprintf_s(cpChars, "-Djava.class.path=%s", classPath); // classpath is defined elsewhere
JavaVMOption options[1];
options[0].optionString = cpChars;
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_6;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
pin_ptr<JNIEnv*> env = &m_env;
pin_ptr<JavaVM*> jvm = &m_jvm;
int result = pfnCreateJavaVM(jvm, (void**)env, &vm_args);
// This is where the failure occurs. result is -3 for some reason here...why?For some reason, pfnCreateJavaVM is returning -3, but I'm not sure why? Any ideas what is wrong with this code, such that it would give me a -3?
Thanks in advance,
Bill

wkoscho wrote:
For some reason, pfnCreateJavaVM is returning -3, but I'm not sure why? Any ideas what is wrong with this code, such that it would give me a -3?As an experiment try using a different jvm.dll from a different location. From my box there are several different jvm.dll under my jdk install dir.

Similar Messages

  • Win2000 & 1.4.0 Beta2: Could not load jvm.dll

    Question: How does 1.4 Beta2 find it's resources?
    When trying to run Install Anywhere 4.5, I get the error message:
    Can't launch executable.
    Could not load jvm.dll
    Try re-installing the Java VM and change the java VM used by the application
    The call is
    D:\Compiere2\jre\bin\java.exe -Xms16777216 -Xmx50331648 -noverify com.zerog.lax.LAX C:\\Temp\\I1003700413\\Windows\\CUpdate.lax C:\\Temp\\env.prop
    OK, I have about 4 different SDKs installed and I heard that if you deinstall everything else and just install 1.4 Beta 2 - it supposetly works. This is not an option, if you try to install/upgrade an application where the user does not know that a VM is.
    The environment:
    JAVA_HOME is set to a 1.4.0 Beta 2 JRE and the PATH is also pointing to the \bin directory ... and in their server/client sub-directories is the jvm.dll
    I guess, that some registry entry is used ... but where do I find that?

    You're running Java2 from "D:\Compiere2\jre". Does the file "D:\Compiere2\jre\bin\hotspot\jvm.dll" exist? And is this the installation which is Java 1.4?
    As far as where the registry entry is kept, it is in HKEY_LOCAL_MACHINE/Software/JavaSoft. However, this value only seems to be used when you run the java.exe which Sun install in the Windows system directory.

  • Failed to load JVM.dll

    Hi
    I am trying to upload report templates in 8.1.1.3, but getting below error.
    SBL-EAI-05006: Failed to load the JVM Dll. Check that the specified dll name is correct.
    Object manager error: ([0] Failed to load the JVM Dll. Check that the specified dll name is correct.(SBL-EAI-05006) (0x23138e))
    SBL-OMS-00107: Object manager error: ([0] Failed to load the JVM Dll. Check that the specified dll name is correct.(SBL-EAI-05006) (0x23138e)).
    And I tried to set JVM DLL Name in profile configuration for XMLPSubSys component, and tried with all JVM dll file location paths in our server enviornment.
    also tried to find C:\PROGRA~1\Java\JDK15~1.0_0\jre\bin\server\jvm.dll unfortunately i didn't find this path.
    Can any one share the solution how can I create or set the correct path for above error?
    Thanks
    Sean

    Hi Sean,
    if you cannot find the path C:\PROGRA~1\Java\JDK15~1.0_0\jre\bin\server\jvm.dll manually, then it's clear that Siebel can also not find it.
    Make sure you have a supported JRE or JDK installed on your machine or on the Siebel server, and that the path is correct.
    In case of Siebel Web Client:
    * Java needs to be installed on the Siebel server
    * The DLL property of the named subsystem you mentioned must point directly to the jvm.dll file (e.g. C:\Program Files\Java\jre6\bin\client\jvm.dll)
    In case of Siebel Mobile/Developer Client:
    * Java needs to be installed on the client
    * The DLL property in the subsystem defined in the client's CFG file (e.g. siebel.cfg) must point directly to the jvm.dll file (e.g. C:\Program Files\Java\jre6\bin\client\jvm.dll)
    Benny

  • Cannot load jvm.dll

    I have installed j2sdk 1.4.2, on windows ME. it seems to have installed ok, but when i try to run it, i just get a message saying "cannot load jvm.dll" Any suggestions?

    I have installed j2sdk 1.4.2, on windows ME. it seems
    to have installed ok, but when i try to run it, i just
    get a message saying "cannot load jvm.dll" Any
    suggestions?Are you using NetBeans?
    If yes, look here:
    http://forum.java.sun.com/thread.jsp?forum=14&thread=434036

  • Can't load jvm.dll

    the following simple code can't load jvm.dll
    at windows xp sp2 ,
    jre-1_5_0_11
    #include <jni.h>
    #include <stdio.h>
    int main() {
         HINSTANCE hVM;
    if((hVM = LoadLibray("C:\\Program Files\\Java\\jre1.5.0_11\\bin\clien\\jvm.dll"))==NULL){
    printf("faild\n");
    else
    printf("succes\n");
         return 0;
    }

    #include <iostream>
    #include <stdlib.h>
    #include <windows.h>
    using namespace std;
    int main(int argc, char *argv[])
    HINSTANCE hVM;
    char *path="C:\\Program Files\\Java\\jre1.5.0_11\\bin\client\\jvm.dll";
    if((hVM = LoadLibrary(path))==NULL){
    printf("Error : %d\n",GetLastError());
    else{
    printf("succes\n");
    FreeLibrary(hVM);
    return 0;
    }

  • IDE Cannot load jvm.dll - what fixes this?

    Hi,
    I have Sun One Community Edition installed.
    I then installed Java web start again and now when I try and run Sun One Community Edition it return the following error:
    IDE
    Cannot load jvm.dll
    Any suggestions as to where I can find information on this or what the fix is.
    Why cant sun package 1 product, rather than having to install Sun ONE App Server, then find it dosnt work, then install J2EE to fix that, now find Sun One does not work...

    Maybe an incompatible jvm.dll is now in the PATH? I've never used Sun One but it's one possibility...

  • "Cannot load jvm.dll" please help solve

    Hello
    I downloaded and installed the following onto windows 98 SE :
    JavaSE installed @ C:\Program Files\Java\j2re1.4.2
    Java2 SDK installed @ C:\Program Files\j2sdk_nb
    NetBeans installed @ C:\Program Files\j2sdk_nb\netbeans3.5
    When I start NetBeans using the desktop shortcut, I get IDE Alert "Cannot Load jvm.dll"
    Can anyone explain to me what I have done wrong and what I have to do in order to put it right.
    I found some stuff about editing 'paths to jvm.dll' but I have found 5 jvm.dll files... which one do I use?
    C:\Program Files\j2sdk_nb\_jvm\jvm.dll
    C:\Program Files\j2sdk_nb\_jvm\bin\classic\jvm.dll
    C:\Program Files\j2sdk_nb\_jvm\bin\hotspot\jvm.dll
    C:\Program Files\j2sdk_nb\_jvm\bin\server\jvm.dll
    C:\Program Files\Java\j2re1.4.2\bin\client\jvm.dll
    Can anyone help me get started getting started with Java?
    Thank you

    Hi
    I have just been suffering with the same problem and managed to find a solution based on answers in these very forums
    What worked for me was to add an entry into the ide.cfg file which told netbeans which folder my JDK was installed in.
    All you need to do is add the following line into the config file (which is in the bin folder under wherever you installed NetBeans 3.5) and it should start up (obviously you will need to change the folder name to match wherever you have your Java development kit)
    -jdkhome d:\JDK1.3
    Hope this works as well for you as it did for me
    Phil

  • How to load jvm.dll (in C++) ?

    Hi friends,
    I've started using JVM for one of my software. I've understood how it works.
    But now i want to create my own application which can take any .class or .jar file and then start executing the same through my program (C++).
    I don't know from where to start. Can anybody help me? (May be with some sample code of C++ for the same?)
    Thanks in advance

    Thanks for responding my query,
    But i'm aware of how to load any dll in C++, but i want to know which functions are avaible with jvm.dll and help on those functions.
    For example JNIenv or some thing is used in C++ which is related to java environment. So what do that mean?
    If i want to know how many classes exist in given jar file then which method out of jvm.dll should i go for?
    If some I get some program, that will be beneficial.
    Thanks again.

  • How to dynamically load jar files - limiting scope to that thread

    Dynamically loading jar files has been discussed a lot. I have read a quite a few posts, articles, and demo code for doing just that. However, I have yet to find a solution to my problem. Most people modify their system class loader and are happy. I have done that and was happy for a time. Occasionally, you will see reference to an application server or tomcat or some other large project that have successfully been able to load and unload jar files, allow for dynamic deployment of code, etc. However, I have not been able to achieve similar success; And my problem is much less complicated.
    I have an application that executes a thread to send a given file/message to a standard JMS Server Queue. Depending on the parameters selected by the user, this thread may need to communicate with one of a number of JMS Servers, ie. JBoss, WebLogic, EAServer, Glassfish, etc. All of which can be done with the same code, but each needs to load their own flavor of JMS Client Jar files. In this instance, spawning a separate JVM for each communication would work from a classloader perspective. However, I need to keep it in the family and run under the same JVM, albeit each JMS Server Connection will be created and maintained in separate Threads.
    I am close, I am doing the following...
    1. Creating a new URLClassLoader in the run() method of each thread.
    2. Set this threads contextClassLoader to the new URLClassLoader.
    3. Load the javax.jms.JMSException class with the URLClassLoader.loadClass() method.
    4. Create an initialContext object within this thread.
    Note: I read that the initialContext and subsequent conext lookup calls would use the Thread�s
    contextClassLoader for finding/loading classes.
    5. Perform context.lookup calls for a connectionFactory and Queue name.
    6. Create JMS Connection, etc. Send Message.
    Most of this seems to work. However, I am still getting a NoClassDefFoundError exception for the javax.jms.JMSException class ( Note step #3 - tried to cure unsuccessfully).
    If I include one of the JMS Client jar files ( ie wljmsclient.jar for weblogic ) in the classpath then it works for all the different JMS Servers, but I do not have confidence that each of the providers implemented these classes that now resolve the same way. It may work for now, but, I believe I am just lucky.
    Can anyone shine some light on this for me and all the others who have wanted to dynamically load classes/jar files on a per Thread basis?

    Thanks to everyone - I got it working!
    First, BenSchulz' s dumpClassLoader() method helped me to visualize the classLoader hierarchy. I am still not completely sure I understand why my initial class was always found by the systemClassLoader, but knowning that - was the step I needed to find the solution.
    Second, kdgregory suggested that I use a "glue class". I thought that I already was using a "glue class" because I did not have any JMSClient specific classes exposed to the rest of the application. They were all handled by my QueueAdmin class. However...
    The real problem turned out to be that my two isolating classes (the parent "MessageSender", and the child "QueueAdmin") were contained within the same jar file that was included in the classpath. This meant that no matter what I did the classes were loaded by the systemClassLoader. Isolating them in classes was just the first step. I had to remove them from my jar file and create another jar file just for those JMSClient specific classes. Then this jar file was only included int custom classLoader that I created when I wanted to instantiate a JMSClient session.
    I had to create an interface in the primary jar file that could be loaded by the systemClassLoader to provide the stubs for the individual methods that I needed to call in the MessageSender/QueueAdmin Classes. These JMSClient specific classes had to implement the interface so as to provide a relationship between the systemClassLoader classes and the custom classLoader classes.
    Finally, when I loaded and instantiated the JMSClient specific classes with the custom classLoader I had to cast them to the interface class in order to make the method calls necessary to send the messages to the individual JMS Servers.
    psuedu code/concept ....
    Primary Jar File   -  Included in ClassPath                                                      
    Class<?> cls = ClassLoader.loadClass( "JMSClient.MessageSender" )
    JMSClientInterface jmsClient = (JMSClientInterface) cls.newInstance()                            
    jmsClient.sendMessage()                                                                      
    JMSClient Jar File  -  Loaded by Custom ClassLoader Only
    MessageSender impliments Primary.JMSClientInterface{
        sendMessage() {
            Class<?> cls=ClassLoader.loadClass( "JMSClient.QueueAdmin" )
            QueueAdmin queueAdmin=(QueueAdmin) cls.newInstance()
            queueAdmin.JMSClientSpecificMethod()
        }

  • Can't load jvm.dll in Vista

    I have a bizarre problem with JDK1.6.0_03 and Windows Vista. I am trying to compile and run a C program that calls a Java method, using the invocation API. In the past, this worked like a charm, provided I had c:\Program Files\Java\jdk1.6.0_03\jre\bin\client on the PATH.
    It no longer works. I get an error message that jvm.dll was not found and that Windows will notify me if it finds a solution to my problem. (I am not holding my breath.)
    I then try to load the library manually:
       HINSTANCE h = LoadLibrary("c:\\Program Files\\Java\\jdk1.6.0_03\\jre\\bin\\client\\jvm.dll");
       if (h == NULL)
           printf("Can't load library\n");
           exit(1);
         }I get the exact same error message.
    Did something break in Vista, or do I need to look elsewhere for a stupid configuration error?
    Thanks,
    Cay Horstmann

    Just in case some other poor soul gets to this, here is the way to implement the invocation under Windows Vista:
    #include <jni.h>
    #include <stdlib.h>
    #include <windows.h>
    typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **, JNIEnv **, JavaVMInitArgs *);
    int main()
       JavaVMOption options[2];
       JavaVMInitArgs vm_args;
       JavaVM *jvm;
       JNIEnv *env;
       long status;
       jclass class_Welcome;
       jclass class_String;
       jobjectArray args;
       jmethodID id_main;
       HINSTANCE h1, h2;
       CreateJavaVM_t createJavaVM;
       h1 = LoadLibrary("c:\\Program Files\\Java\\jdk1.6.0_03\\jre\\bin\\msvcr71.dll");
       if (h1 == NULL)
          printf("Can't load library msvcr71.dll\n");
          exit(1);
       h2 = LoadLibrary("c:\\Program Files\\Java\\jdk1.6.0_03\\jre\\bin\\client\\jvm.dll");
       if (h2 == NULL)
          printf("Can't load library jvm.dll\n");
          exit(1);
       options[0].optionString = "-Djava.class.path=.";
       memset(&vm_args, 0, sizeof(vm_args));
       vm_args.version = JNI_VERSION_1_2;
       vm_args.nOptions = 1;
       vm_args.options = options;
       createJavaVM = (CreateJavaVM_t) GetProcAddress(h2, "JNI_CreateJavaVM");
       status = (*createJavaVM)(&jvm, &env, &vm_args);
       if (status == JNI_ERR)
          printf("Error creating VM\n");
          return 1;
       class_Welcome = (*env)->FindClass(env, "Welcome");
       id_main = (*env)->GetStaticMethodID(env, class_Welcome, "main", "([Ljava/lang/String;)V");
       class_String = (*env)->FindClass(env, "java/lang/String");
       args = (*env)->NewObjectArray(env, 0, class_String, NULL);
       (*env)->CallStaticVoidMethod(env, class_Welcome, id_main, args);
       (*jvm)->DestroyJavaVM(jvm);
       return 0;
    }Compile with
    gcc -g -mno-cygwin -D __int64="long long" -I /cygdrive/c/Program\ Files/Java/jdk1.6.0_03/include/ -I /cygdrive/c/Program\ Files/Java/jdk1.6.0_03/include/win32/ -o InvocationTest InvocationTest.c Of course, in a real application, you'll want to dynamically locate the Java directory; look at launcher/java_md.c inside src.zip for inspiration.

  • Error loading jvm.dll - urgent!!

    Hi,
    When I try to compile using javac, I get an error as stated below:
    Error loading: y:\sys\nt\j2sdk-1_3_1\jre\bin\hotspot\jvm.dll
    What am I missing?
    Thanks

    check if jvm.dll exists in y:\sys\nt\j2sdk-1_3_1\jre\bin\hotspot. May not be a good solution but try to uninstall and re-install j2sdk. Also check ur CLASSPATH settings
    Vinay

  • How to dynamically load images into Flash

    I have a movie clip on the stage that I want to dynamically
    load images into (that constantly change), how would I go about
    doing this? Thanks.

    Use the Loader class to load in images.
    Then use addChild to add the Loader class into your MovieClip
    on the stage.
    As far as &amp;quot;constantly change&amp;quot; what
    do you mean by that? You could use setInterval, ther enterFrame
    event, or any other means to trigger a new image to be loaded into
    the Loader instance.
    Finally, you can use the Tween class to create some nice
    effects for the images (fade it, blur in, photo blend, masks,
    etc)

  • Error Loading JVM.dll on WinNT

    Hi
    We have recently, installed Oracle Apps 11i. While applying a patch on Apps 11i, we were getting a Java error - Error Loading: ...\classic\jvm.dll. And we are unable to apply the Apps11i patch.
    I checked the entire Server for JVM.dll, but could not find it.
    After checking this forum, I found, that, a similar BUG in Java has been reported, but most of the BUG descriptions are for WIN 95 and WIN2K and NOT for WinNT.
    Could someone help me out.
    Enviroment Info:
    Product :- Oracle Apps 11i
    Platform :- WinNT 4.0
    Regards
    Vinod

    jvm.dll should be in the <java>\bin\classic directory.
    If it's not, then I THINK there's something wrong with your java runtime environment (jre).
    Is this something you installed yourself - the java - or was it soemthing dropped on yoour system by the Oracle product?
    o former: Get a new jre.
    o Latter: Get a new jre and/or complain to Oracle.

  • Error loading jvm.dll

    our company has an application that we use for company business that runs off Java.  Lately, I have several users that can no longer launch the application.   All are receiving the same error "The Java Runtime Environment cannot be loaded from <C:\PROGR~2\Oracle\JINITI~1.18\ bin\hotspot\jvm.dll>   We are running IE 10, Window 7 and latest version of Java. I did however try to use an older version of Java to no avail.  Any assistance will be greatly appreciated.

    jvm.dll should be in the <java>\bin\classic directory.
    If it's not, then I THINK there's something wrong with your java runtime environment (jre).
    Is this something you installed yourself - the java - or was it soemthing dropped on yoour system by the Oracle product?
    o former: Get a new jre.
    o Latter: Get a new jre and/or complain to Oracle.

  • Loading a DLL without JNI

    I'm new to java, but I've been programming for a long time, and I'm looking for a way to load a DLL into java. I see a lot of places online that talk about using JNI, but I'm terrible with C++, so that's not really an option for me.
    I also see various places that say you can just use System.load("C:/...x.dll") but none of them have code for actually executing one of the methods in x.dll...
    Thanks in advance,
    bmad6

    You may want to check out something called Jacob - this is a Java to COM bridge (hence the name I guess) and you should be able to get it either at Sourcforge, download.com or by searching the 'net.

Maybe you are looking for

  • Creation Of Oracle Processes in Solaris

    I am having Oracle 8.1.7.2 installed on Sun Solaris Server. I am accessing Oracle from my application through iPlanet Web Server---> iPlanet Application Server. The problem is that as soon as my Application goes up and users start logging in the numb

  • 2009 macbook pro incorrect number of file hard links. repaired and still slow. I replaced the hard drive within the year and it's 1 tb not full. help!

    I have a 2009 macbook pro and I keep it up to date. I replaced the hard drive with a new 1 tb hard drive within the last year. It is not even close to full. The other night I was doing a time machine backup and the spinning color wheel appeared. It w

  • Cash Flow (Direct Method ) Report ( T-Code S_ALR_870_12271 ) not Working

    Hi All,          I am trying to run Cash Flow (Direct Method ) Report with T-Code S_ALR_870_12271 but it's showing Output  as following .      No records were selected                Table     Financial Statement Key Figures      Report name     0SAP

  • 10.5.6

    Is the four finger swipe there after you update for the 1st gen MBA I was just wondered if anybody saw it. I read that it is there for those people who have the 2nd gen and the gesture was not there.

  • DNS request timed out. timeout was 2 seconds

    Hi Why it is saying DNS request timed out was 2 seconds and showing the IPs under non-authoritative answers? This is member DC windows 2008 R2. Primary DNS is set as 127.0.0.1 and secondary DNS is set to 192.168.10.6 which is main DC. C:\Users\admin>