JNI Version Wrong? Error Code = JNI_EVERSION

Hi people,
I have a jar file and I want to call those jar-file-methods from my C++ Project. B'coz I never have used JNI, I would like to create a simple example to see how is that running:
[JAVA]public class HelloFunc {
     static {
          System.mapLibraryName("HelloFunc");
     public static void main(String[] args) {
          if (args.length > 0) System.out.println("Hello World " + args[0]);
          else System.out.println("Hello World /wo Args!");
}[JAVA]
I exported that Java programm above with Eclipse as an executable jar file, which is used in the project below. In his case I want to call the main-Method from my C++ project:
[CPP]#include <jni.h>
#include "JNI_IF.h"
// C:\Program Files\Java\jdk1.6.0_26\lib
#pragma comment (lib,"C:\\Program Files\\Java\\jdk1.6.0_26\\lib\\jvm.lib")
JNI_IF::JNI_IF(char* JVMOptionString)
     JavaVMInitArgs vm_args;
     JavaVMOption options[1];
     options[0].optionString = JVMOptionString;
     vm_args.options = options;
     vm_args.nOptions = 1;
     vm_args.version = JNI_VERSION_1_6;
     vm_args.ignoreUnrecognized = JNI_FALSE;
void JNI_IF::setClassName(char* className)
     result = JNI_CreateJavaVM( &jvm,(void **)&env, &vm_args);
     switch(result)
          case JNI_ERR:
               printf("Unknown Error invoking the JVM\n");
               return;
          case JNI_EDETACHED:
               printf("Thread detached from the JVM\n");
               return;
          case JNI_EVERSION:
               printf("JNI version error\n");
               return;
          case JNI_ENOMEM:
               printf("Not enough memory the JVM\n");
               return;
          case JNI_EEXIST:
               printf("JVM already created\n");
               return;
          case JNI_EINVAL:
               printf("Invalid arguments\n");
               return;
          case JNI_OK:
               printf("JVM created --> Ready ...\n");
     cls = env->FindClass(className);
     if( cls == NULL ) {
          printf("can't find class %s\n", className);
          return;
     env->ExceptionClear();
void JNI_IF::setMethodName(char* methodName)
     mid = env->GetStaticMethodID(cls, methodName, "([Ljava/lang/String;)V");
     if (mid != NULL){
          env->CallStaticVoidMethod(cls,mid,"70");
int main()
     JNI_IF JNIInterfaceObj("-Djava.class.path=M:\\Eigene Dateien\\Visual Studio 2008\\Projects\\JNI_IF\\JNI_IF;M:\\Eigene Dateien\\Visual Studio 2008\\Projects\\JNI_IF\\JNI_IF\\hello.jar");
     JNIInterfaceObj.setClassName("HelloFunc");
     JNIInterfaceObj.setMethodName("main");
     return 0;
}[CPP]
And my corresponding header:
[HEADER]#ifndef JNI_IF_H
#define JNI_IF_H
#include <jni.h>
class JNI_IF {
public:
     JNI_IF(char* JVMOptionString);
     void setMethodName(char* methodName);
     void setClassName(char* className);
private:
     JavaVMInitArgs vm_args;
     JavaVM *jvm;
     JNIEnv *env;
     //JNINativeInterface *env;
     long result;
     jmethodID mid;
     jfieldID fid;
     jobject jobj;
     jclass cls;
     int asize;
     char  JVMOptionString[20];
     char  className[20];
     char  methodName[20];
     JavaVMOption options[1];
#endif[HEADER]
According to my debugger, I always got a JNI_EVERSION error --> so the JNI_CreateJavaVM() fails. Hows that be? I tried every versions JNI_VERSION_1_1, JNI_VERSION_1_2, JNI_VERSION_1_4 and JNI_VERSION_1_6. All the same error.
Windows XP Prof. SP 3, Visual Studio 2008, JDK 1.6.0_26. I linked the lib statically as you can see and the jvm.dll is in my projects debug folder.
I can compile and start the programm, but as I said, I got that error code.
I appreciate every hints and solutions, thank you for your patience.
Cheers
Edited by: 872444 on 14.07.2011 01:03
Edited by: EJP on 8/09/2011 18:38: code tags

There are several major problems with this code.
JNI_IF::JNI_IF(char* JVMOptionString)
     JavaVMInitArgs vm_args;
     JavaVMOption options[1];
     options[0].optionString = JVMOptionString;
     vm_args.options = options;
     vm_args.nOptions = 1;
     vm_args.version = JNI_VERSION_1_6;
     vm_args.ignoreUnrecognized = JNI_FALSE;
}So I assume vm_args is a class member. However you are setting vm_args.options to the address of a variable that will disappear as soon as this constructor exits. This is almost certainly the cause of your immediate problem, and if it isn't it will certainly cause problems further down the track. I would move most of code from setClassName() into here to address that.
void JNI_IF::setClassName(char* className)
     result = JNI_CreateJavaVM( &jvm,(void **)&env, &vm_args);
     switch(result)
          case JNI_ERR:
               printf("Unknown Error invoking the JVM\n");
               return;
          case JNI_EDETACHED:
               printf("Thread detached from the JVM\n");
               return;
          case JNI_EVERSION:
               printf("JNI version error\n");
               return;
          case JNI_ENOMEM:
               printf("Not enough memory the JVM\n");
               return;
          case JNI_EEXIST:
               printf("JVM already created\n");
               return;
          case JNI_EINVAL:
               printf("Invalid arguments\n");
               return;
          case JNI_OK:
               printf("JVM created --> Ready ...\n");
     }All that should be in the constructor.
     cls = env->FindClass(className);So it appears that 'cls' is also a member.
     if( cls == NULL ) {
          printf("can't find class %s\n", className);
          return;
     }If 'cls' was null there was an exception, and you should print it rather than making up your own message. You are losing information.
     env->ExceptionClear();Conversely if 'cls' isn't null there was no exception so there is nothing to clear here.
void JNI_IF::setMethodName(char* methodName)There's not much point in making this a separate method. I would have one setEntryPoint() method that takes the classname and the method name. However as the method name has to be 'main' there's not much point in making it a parameter.
     mid = env->GetStaticMethodID(cls, methodName, "([Ljava/lang/String;)V");And here for example you are using a methodName parameter but a hardwired argument-list. So again there wasn't much point in the methodName parameter.
     if (mid != NULL){
          env->CallStaticVoidMethod(cls,mid,"70");... else you should print something ... an exception. Otherwise you are again losing information. The program does nothing and silently exits. Not very informative. And this proves that the method is poorly named. You aren't just setting a method name, you are +calling+ it. I would say the method should be called run(), with no arguments.

Similar Messages

  • Unsupported java version, the error code is FMR 92095

    help me, i have a problem whit unsupported java version, the error code is FMR 92095. I am working whit os windows 7 and mozilla firefox.
    there are java version 1.1.8.2. ?
    How i can download ?

    Hi,
    Try post a comment in B1DE 2.0.1 new version! blog.
    Beni.

  • I got an "RPC version wrong" error on mounting an NFS volume

    Hi all,
    I'm having a problem with my NAS (CHS3SNAS) when trying to mount the exported volumens on the imac (OSX 1.5.2). When doing mount or mount_nfs I always get the following error:
    "RPC version wrong"
    NAS is using a nfs-utils-1.1.0 compiled for the linux OS it is running. When I use rpcinfo -p <nas-ip> from the iMac to the NAS everything seems OK (nfs, portmap and mount daemons appear).
    Any clue or hint how to solve or overcome this?
    Thanks !

    It might be helpful to know how exactly the NFS server is configured (e.g. what export options are used) and exactly what NFS mount options are used on the client.
    That's a strange (but not totally out of the question) error to be getting. The error typically means that the NFS server does not support the version of the protocol the NFS client is trying to use.
    You may need to investigate the network packets with a tool like wireshark to get more details.
    HTH
    --macko

  • "Uh-oh, something went wrong! Error Code: 503"

    I keep getting this error code and I've tried everything to fix it but nothing works. Also it only happens on my computer nobody elses

    In the past, if it is not due to the firewall I would recommend trying a new profile:
    *[[Use the Profile Manager to create and remove Firefox profiles]]
    Does this happen in other browsers too?
    This was an interesting reference, but it is a common troubleshooting step on Windows: [http://boonforums.com/index.php?threads/how-to-resolve-the-uh-oh-something-went-wrong-error-code-503-error.4586/]

  • Error Code and Encountering an error

    Error Code: 1403
    Something like Installation of Quicktime Failed.
    ^^that is after download^^
    Now when I try to open up Itunes it says Itunes has encountered an error and needs to close and I'm not sure what's wrong.

    Error Code: 1403
    Something like Installation of Quicktime Failed.
    ^^that is after download^^
    Now when I try to open up Itunes it says Itunes has encountered an error and needs to close and I'm not sure what's wrong.

  • Replication : error code 402

    I've 3 LDAP servers 5.2. Each have same release
    All are master replica
    A have a agreement to C
    B have a agreement to C
    So A & B can replicate to C
    I initialize A -> OK
    I initialize B -> OK
    I update A -> OK C got the new data
    I update B -> NOK
    I become the following error :
    Replication inconsistency Consumer
    Replication session failed, consumer replica has a different data version. Error code 402
    All, A, B and C was created with the same data
    Thank you

    I've 3 LDAP servers 5.2. Each have same release
    All are master replica
    A have a agreement to C
    B have a agreement to C
    So A & B can replicate to C
    I initialize A -> OK
    I initialize B -> OKServer B and C should be initialized from the Server's A data (either with online replica init, or with exporting the data with replication information and reimporting in B and C.
    Ludovic.
    I update A -> OK C got the new data
    I update B -> NOK
    I become the following error :
    Replication inconsistency Consumer
    Replication session failed, consumer replica has a
    different data version. Error code 402
    All, A, B and C was created with the same data
    Thank you

  • Error Code: -18002

    I'm going through the Introduction to TestStand Course Manual and exercise 1.1 and when I run the sequence,
    I see this error.  I installed the evaluation copy of LabVIEW 8 on my PC.  Is there a simple way to convert the VIs
    that came with the course manual from (I think) version 6.x to 8.0?  If not, what do you recommend?  My next
    task involves using TestStand with LabVIEW, CVI, and Agilent VEE modules.  Therefore, I plan to go through
    course manual (I have only the first), and I plan to order the second.  But if all the examples are going to cause
    me this much grief, I'll need to go a different route.
    LabVIEW: VI version is too early to convert to the current LabVIEW version. [Error Code: -18002]

    Hi,
    When you load the VI(s) you affective compile those VI's, if you cannot achieve this at load time then you are not going to achieve using the Mass Compile command.
    What you need to do is bring them up to an intermediate version.
    I think your VIs must be version 5.x
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • I shoot with a Canon 7D, have Windows 7 installed on my computer, Adobe CS4 (Bridge & Photoshop). I'm trying to open the CR2 files in Bridge to adjust them before I open them up in Photoshop, but it's giving me an error code saying it's the wrong file typ

    I shoot with a Canon 7D, have Windows 7 installed on my computer, Adobe CS4 (Bridge & Photoshop). I'm trying to open the CR2 files in Bridge to adjust them before I open them up in Photoshop, but it's giving me an error code saying it's the wrong file type. I downloaded the latest updates for Adobe Raw as well as the DNG converter, however I don't want to have to convert to DNG before opening in Bridge. Please let me know what I can do to open the CR2 files directly in Bridge CS4, thank you!

    Make sure you have the right version...
    Camera Raw plug-in | Supported cameras
    Camera Raw-compatible Adobe applications

  • There was a recent upadate on my PC, however it does not work. A error code comes up which says, min version is not compatible with max version. And I caanot open my browser. Please help.

    I do a system restore which allows me to open my browser. Without this I cannot open my browser - the error code comes up every time.

    Do a clean (re)install
    * Download a fresh Firefox copy from http://www.mozilla.com/firefox/all.html and save the file to the desktop.
    * Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    * Don't remove personal data when uninstalling.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    From https://support.mozilla.com/en-US/questions/764376

  • I get this error code when trying to update from an older version of Firefox: The operation can't be completed because you don't have permission to access some of the items.

    While trying to upgrade from a previous version of Firefox, I get this error code: "The operation can’t be completed because you don’t have permission to access some of the items."
    == installing ==
    == User Agent ==
    Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7

    I resolved the problem in Snow Leopard by logging out of my (admin) account and logging into my daughter's account on the same machine. She doesn't have admin privileges, so when I tried to install Firefox 4 in her account, I had to authenticate with my admin identity and PW. Installation went smoothly after that. My guess is that you could also simply create a new account on the same machine and install Firefox 4 from that. I have no idea why this works.

  • Unable to update itunes. help. error message when trying to update to latest version of itunes. "the installer has encountered an unexpected error installing this package. this may indicate a problem with this package. error code 2721"

    unable to update itunes. help. error message when trying to update to latest version of itunes. "the installer has encountered an unexpected error installing this package. this may indicate a problem with this package. error code 2721"

    Hello chae84swangin,
    I recommend following the steps in the article below when getting an error message trying to install iTunes:
    Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Unable to install update version 1.6.0.393 with error code 3 (Administrator privileges)

    I am unable to update Creative Cloud to version 1.6.0.393. I am running Windows 7 Professional SP1 and have tried installing in administrator profile.
    The message returned when attempting to start the update is:
    Administrator privileges are required to continue with the installation.(Error code: 3)

    Didn't work for me....I have this same problem.
    Tried all this stuff too:
    "Installing Update" Error, Administrator Privileges are required to continue with the installation (Error Code 3)
    I'm on a network as an admin, have tried opening it as an admin, set "always open as admin"....everything.
    MAD

  • After installing the most recent iTunes update/version iTunes will no longer run on my PC.  I receive a window with the Microsoft error code R6034

    After installing the most recent iTunes update/version iTunes will no longer run on my PC (Windows 7).  I receive multiple error windows with the Microsoft error code R6034.  Microsoft's Help site states that this error occurs when a driver attempts to access the C++ library without a "Manifest".  I do not know what a manifest is, but apparently any attempt to directly access the C++ library is not permitted.  The site instructs the viewer to contact the application developer.

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • SAP NetWeaver 2004s ABAP Trial Version - error code = 200

    Hi all,
    installation of SAP NetWeaver 2004s ABAP Trial Version
    which was attached to the book ABAP-Objects ends again and again with
    ProductException: (error code = 200; message="Java error"; exception = java.lang.Exception)
    Attached you find information about
       1) Host-file
       2) Network connections
       4) Error - Log
    It seems that the      [#     [#]
    echo                7/tcp
    echo                7/udp
    discard 
               9/tcp    sink null
    discard             9/udp    sink null
    systat             11/tcp    users            
         #Active users
    systat             11/tcp    users                  #Active users
    daytime            13/tcp
    daytime
               13/udp
    qotd               17/tcp    quote                  #Quote of the day
    qotd               17/udp    quote   
                  #Quote of the day
    chargen            19/tcp    ttytst source          #Character generator
    chargen        
    4) == E R R OR  L O G ================================================
    (Jan 1, 2007 1:07:15 PM), Install, com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles, err,
      an error occurred and product installation failed.  Look at the log file D:SAPNSPlog.txt for details.
    (Jan 1, 2007 1:07:15 PM), Install, com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles, err,
    ProductException: (error code = 200; message="Java error"; exception = java.lang.Exception)
    STACK_TRACE: 15
    ProductException: (error code = 200; message="Java error"; exception = java.lang.Exception)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.execute(StepWrapperInstallFiles.java:254)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.executeAllSteps(StepWrapperInstallFiles.java:224)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.executeAllInstallationSteps(StepWrapperInstallFiles.java:177)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.install(StepWrapperInstallFiles.java:268)
         at com.installshield.product.service.product.PureJavaProductServiceImpl.installProductAction(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$InstallProduct.getResultForProductAction(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitComponent(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitInstallableComponents(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitProductBeans(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$InstallProduct.install(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$Installer.execute(Unknown Source)
         at com.installshield.wizard.service.AsynchronousOperation.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    (Jan 1, 2007 1:12:17 PM), Install, com.installshield.product.service.product.PureJavaProductServiceImpl$InstallProduct, err,
    An error occurred and product uninstallation failed.  Look at the log file D:SAPNSPlog.txt for details.
    (Jan 1, 2007 1:12:17 PM), Install, com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles, err,
    ProductException: (error code = 200; message="Java error"; exception = java.lang.Exception)
    STACK_TRACE: 15
    ProductException: (error code = 200; message="Java error"; exception = java.lang.Exception)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.execute(StepWrapperInstallFiles.java:254)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.executeAllSteps(StepWrapperInstallFiles.java:224)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.executeAllUninstallationSteps(StepWrapperInstallFiles.java:192)
         at com.sap.installshield.sdcstepswrapper.StepWrapperInstallFiles.uninstall(StepWrapperInstallFiles.java:313)
         at com.installshield.product.service.product.PureJavaProductServiceImpl.uninstallProductAction(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$InstallProduct.processActionsFailed(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitComponent(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitInstallableComponents(Unknown Source)
         at com.installshield.product.service.product.InstallableObjectVisitor.visitProductBeans(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$InstallProduct.install(Unknown Source)
         at com.installshield.product.service.product.PureJavaProductServiceImpl$Installer.execute(Unknown Source)
         at com.installshield.wizard.service.AsynchronousOperation.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source
    == Remark to threads ========================
    Thread a)
    "I found it is very useful to have a clean system" => not applicable to me
    Thread b)
    deals with removing relics of previous installations => hints considered but error still appears
    Thread c)
    not applicable to me

    Hi all
    I've read your entrys.
    Saw that the solution is missing.
    It can be found in the manuals:
    1. Download the "Registry Clean Tool for SAP NetWeaver 2004s ABAP" and use it.
    2. Download the latest Version of "SAP NetWeaver 2004s ABAP" and un-rar it.
    3. Install the "Microsoft Loopback Adapter" an activate it.
    4. Retry to install.
    Summary:
    So the error 200 was caused for the first time from trying an installation without a Loopback Adapter, and after that from trying to re-install without cleaning the registry.
    Now its working fine.
    Thomas

  • I have just tried to update my iTunes to version 11.1.4 and now I get an error and iTunes won't install. I get error code 7.

    I have tried to upgrade my iTunes to version 11.1.4. Now I get an error code 7 and can't access iTunes at all. The message says there was a failure to install. I tried to go back to previous version, but that doesn't work, either. Any ideas?

    Solving MSVCR80 issue and Windows iTunes install issues.

Maybe you are looking for

  • Contacts Application crashing after MLion Update

    A friend of mine has updated OS X to Mountain Lion and now when he tries to open contacts app and edit the contacts, it simply crashes. The first thing he did was os x reinstall. Issue wasn't fixed. I thought it could be due the amount of contacts (1

  • Iphoto won't open after upgrade

    I upgraded iPhoto.  Now when I try to open the application, I get a message "the photo libray needs to be updated..."  The spinning circle appears for a while, indicating 'work going on.'  Then the application shuts down.  I download photos to iPhoto

  • Class cast exception about oracle db

    I want to store image file into BLOB of oracle datebase. first, i insert a empty BLOB, like "insert into tableName (blobField, ...) values(empty_blob(), ...)" then, i will retrieve this record to update the BLOB field, like "select blobField from tab

  • How do I get CS4 onto my new macbook?

    I have been using CS4 on my pc for quite a while now and I just switched to a mac. I dont want to upgrade at all. I have my serial number and I want to know where I can download the software that I own.

  • Screen/display problems

    I have a xMII web page (irpt) that will sometimes cause the display/screen to go crazy (don't know how else to describe) - no way to recover besides killing the browser window via the task manager.  Not sure if it is an xMII problem or if a problem w