Can't create Java VM [Code :- 3 ] with JNI_CreateJavaVM()

hello all,
I am trying to create an inctance of JVM from C/CPP ( iam using VC++ editor) on windows. My code to create JVM is :
res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
as a reasult of this call, -3 is returned to res.
please help me to create a JVM and/or call a java class from C/CPP
Thanks in advance,
Soujanya.R

I tried to run it this way :-
#include <jni.h>
#include <windows.h>
#define JNI_EVERSION (-3) /* JNI version error */
#define PATH_SEPARATOR ';'
#define USER_CLASSPATH "." /* where Prog.class is */
void main() {
          JNIEnv *env;
          JavaVM jvm = (JavaVM )0;
          jint res;
          jclass cls;
          jmethodID mid;
          jstring jstr;
          jobjectArray args;
          HINSTANCE hVM = NULL;
          JavaVMInitArgs vm_args;
          JavaVMOption options[4];
          printf("\noptions");
          options[1].optionString = "-Djava.class.path=C:/j2sdk1.4.1_07/jre/lib/rt.jar;E:/test/c/Debug/"; /* user classes */
          options[2].optionString = "-Djava.library.path=lib"; /* set native library path */
          options[0].optionString = "-Djava.compiler=NONE";
          //options[1].optionString = "-Djava.class.path=c:\\My Folder"; /* user classes */
          //options[2].optionString = "-Djava.library.path=C:\\j2sdk1.4.2_04\\include";
          options[3].optionString = "-verbose:jni";
          printf("\nversion info");
          vm_args.version = JNI_VERSION_1_2;
          vm_args.options = options;
          vm_args.nOptions = 4;
          vm_args.ignoreUnrecognized = TRUE;
          printf("\ncreate");
          hVM = LoadLibrary("C:/j2sdk1.4.1_07/jre/bin/client/jvm.dll");
          if (hVM == NULL)
               printf("hVM is null ");
          res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
          if (res < 0) {
               fprintf(stderr, "Can't create Java VM \n",res);
               exit(1);
          cls = env->FindClass("HelloWorld");
          //cls = env.FindClass(env,"helloWorldClass");
          if (cls == 0) {
               fprintf(stderr, "Can't find Prog class\n");
               exit(1);
          mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
          if (mid == 0) {
               fprintf(stderr, "Can't find Prog.main\n");
               exit(1);
          jstr = env->NewStringUTF(" from C!");
          if (jstr == 0) {
               fprintf(stderr, "Out of memory\n");
               exit(1);
          args = env->NewObjectArray(1, (*env).FindClass("java/lang/String"), jstr);
          if (args == 0) {
               fprintf(stderr, "Out of memory\n");
               exit(1);
          env->CallStaticVoidMethod(cls, mid, args);
          jvm->DestroyJavaVM();
I could run the program.
You need to have the C:\j2sdk1.4.1_07\lib\jvm.lib entries in Project->Settings->Link Tab
When you open the Settings dialog box you will see Win32Debug in the
drop down . You need to provide the entries for that page .
Then change the drop down to Win32 Release and make an entry similarly there too.
You should be able to run your code.
Vishal                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Can't create Java VM ?

    Hi,
    I tried to invoke JavaVM in C. And use the example from http://java.sun.com/docs/books/tutorial/native1.1/invoking/invo.html.
    But when runed it after compiled it in Win32 with VC6.
    It just can't create the VM. The following is the source:
    ========================================
    #include <jni.h>
    #ifdef _WIN32
    #define PATH_SEPARATOR ';'
    #else /* UNIX */
    #define PATH_SEPARATOR ':'
    #endif
    #define USER_CLASSPATH "." /* where Prog.class is */
    main() {
         JNIEnv *env;
         JavaVM *jvm;
         jint res;
         jclass cls;
         jmethodID mid;
         jstring jstr;
         jobjectArray args;
         char classpath[1024];
         JavaVMInitArgs vm_args;
         JavaVMOption options[4];
         options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
         options[1].optionString = "-Djava.class.path=.";                     /* user classes */
         options[2].optionString = "-Djava.library.path=.";                /* set native library path */
         options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
         vm_args.version = JNI_VERSION_1_2;
         vm_args.options = options;
         vm_args.nOptions = 4;
         vm_args.ignoreUnrecognized = 1;
    JNI_GetDefaultJavaVMInitArgs(&vm_args);
    /* Append USER_CLASSPATH to the end of default system class path */
    //sprintf(classpath, "%ls%c%s", vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
    //vm_args.classpath = casspath;
    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
    if (res < 0) {
    fprintf(stderr, "Can't create Java VM\n");
    exit(1);
    cls = (*env)->FindClass(env, "Prog");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    mid = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");
    //mid = (*env)->GetMethodID(cls, "Yup","(I)Ljava/lang/String;"); /* Search the Method of class*/
    if (mid == 0) {
    fprintf(stderr, "Can't find Prog.main\n");
    exit(1);
    jstr = (*env)->NewStringUTF(env, " from C!");
    if (jstr == 0) {
    fprintf(stderr, "Out of memory\n");
    exit(1);
    args = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env, "java/lang/String"), jstr);
    if (args == 0) {
    fprintf(stderr, "Out of memory\n");
    exit(1);
    (*env)->CallStaticVoidMethod(env, cls, mid, args);
    (*jvm)->DestroyJavaVM(jvm);
    ========================================
    Would you please to tell me why it failed and please show me a simple example ?
    Best regards,
    Eric

    I have the same problem,
    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm, (void **)&env,
    nv, &vm_args);
    if (res < 0) {
    fprintf(stderr, "Can't create Java VM: %d\n",
    %d\n", res);
    exit(1);
    res is -1...but I'm not using windows, I'm using Linux
    and Solaris...Hi there,
    I also have problem calling JNI_CreateJavaVM on Linux (returns -1). Have you been able to solve this in the meantime?

  • How can I create a new TC backup with ethernet, so I don't have to wait two days for a new wireless backup?

    How can I create a new TC backup with ethernet, so I don't have to wait two days for a new wireless backup?
    Several times in the last year, I've gotten a message that Time Machine needs to completely redo my backup. Using the wireless connection, this takes almost two days. Is there a way to do the backup with ethernet and then switch back to wireless? Thanks.

    May I know what is needed to make sure the MacBook is able to see Time Capsule on ethernet?
    Connect an Ethernet cable from one of the LAN <-> ports on the 2Wire gateway to the WAN port (circle of dots icon) on the Time Capsule.
    If AirPort Utility cannot "see" the Time Capsule now, you will need to perform a "hard reset" by holding in the reset button for 7-8 seconds or so and then reconfigure the Time Capsule. You can use the same Time Capsule name and password, etc. as before.
    Configure the Time Capsule to "Create a wireless network" and select the Bridge Mode option when it appears during the setup using AirPort Utility.
    Once the Time Capsule is configured, restart the entire network again. Power down everything, start the 2Wire first and then start each other device after that one at a time about a minute apart.
    Now you can connect your Mac directly to one of the LAN <-> ports on the Time Capsule for the backup using another Ethernet cable. In general, about 20-25 GB per hour will transfer.
    The Time Capsule will broadcast a much faster wireless network than the 2Wire can provide, so you might want to leave the setup "as is" for awhile after the first backup is complete. If you decide to use the Time Capsule as your main wireless access point, you would want to turn the wireless off on the 2Wire since two wireless networks in close proximity can create interference problems.
    Or, if you want to use the wireless on the 2Wire, you could turn off the wireless on the Time Capsule. Then backups will occur over the 2Wire wireless, or over Ethernet.
    I don't really recommend the "Join a wireless network" setting on the Time Capsule for most users, but you could go back to that setup as well if you want after the first backup is complete.

  • Can we create the Application name starting with Numerics

    Hi All,
    can we create an application name stating with number like 1234Samsung.
    Also can we use the special characters between them.
    Also are there any rules for creating database names other than maximum 8 characters limit.
    Regards

    Hi,
    1. You can create starting with numerics, 123samsu.
    2. samsung cannot complete ,the know reason is exceeding 8
    Sandeep Reddy Enti
    HCC
    http://hyperionconsultancy.com/

  • Can I create a website like Twitter with Creative Cloud?

    Can I create a website like Twitter with Creative Cloud?

    Start with jQuery Calculation plugin.   Tweak values as required.
    http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com/

  • Can i create an exetutable (.exe) program with java???????

    I would like to learn how i can create an exetutable (.exe) program with java.
    Is there any additional package which i should download or buy it?
    Also i would like to write files into CD's direct from my application.
    Is there any library which i must download or buy?
    Thanks!

    check out the free open source GNU gcj native compiler for Java to see if it will do what you want.
    http://gcc.gnu.org/java/
    for writing data files you could use java.io.BufferedWriter. For sound files, look in the javax.sound package

  • How can I create a new Care Plan with one or more care tasks

    Hello,
    I'm working on a Dutch website in the HealthVault Environment. I got difficulties in creating and updating a careplan with care tasks. Most likely it's due to lack of knowledge...
    Following code works fine:
    CarePlan plan = new CarePlan();
    plan.Name = "test";
    this.PersonInfo.SelectedRecord.NewItem(plan);
    It creates a plan called [test]. But I don't know how to create a plan with one or more tasks in it: the tasks property is read only.
    https://msdn.microsoft.com/en-us/library/microsoft.health.itemtypes.careplan.tasks.aspx
    Half a year ago I was able to add an example of a careplan, which was a feature of the dev tools, but for some reason that's not possible anymore.
    https://developer.healthvault.com/DataTypes/Overview?TypeId=415c95e0-0533-4d9c-ac73-91dc5031186c
    So my question is, how can I add a new care plan with a task like the example from the HealthVault dev tools:
    <tasks>
    <task>
    <name>
    <text>Run 100 miles</text>
    </name>
    <description>Run 100 miles in 6 months</description>
    <start-date>
    <structured>
    <date>
    <y>2013</y>
    <m>12</m>
    <d>1</d>
    </date>
    </structured>
    </start-date>
    <end-date>
    <structured>
    <date>
    <y>2014</y>
    <m>6</m>
    <d>1</d>
    </date>
    </structured>
    </end-date>
    <target-completion-date>
    <structured>
    <date>
    <y>2014</y>
    <m>12</m>
    <d>31</d>
    </date>
    </structured>
    </target-completion-date>
    <sequence-number>279128532</sequence-number>
    <recurrence>
    <interval>
    <text>Once</text>
    </interval>
    <times-in-interval>10</times-in-interval>
    </recurrence>
    <reference-id>p01vil21ckg7k2346y1g60337mmi20sg564l321l8pmpqev39n302572sewu76lh9019s3993e02924</reference-id>
    </task>
    </tasks>
    Any help is welcome 
    Wilfred

    Hi Wilfred,
    Have you tried this?
    CarePlan plan = new CarePlan();
    plan.Name = "test";
    plan.Tasks.Add(someTask) 
    If you have a task list already, you would need to enumerate through it and add one by one...
    foreach (var task in existingList)
        plan.Tasks.Add(task)

  • How can I create unique partnerships to deal with like EDI messages?

    I have an EDI to Application partnership setup currently that deals with translating MEDRUC type EDIFACT messages to a mainframe format. The setup is
    Sender = PARTNERA,
    Receiver = PARTNERB
    DocType = MEDRUC.
    In the Input EDI tab the
    Sender Qualifier ID = ZZ:PARTNERA
    Receiver Qualifier ID = ZZ:PARTNERB
    Standard = EDIFACT
    Version = D
    Release Number = 97B.
    Use UNG to locate partnerships = No
    EDIFACT messages contain all this information in their UNB and UNH segments which is where SunONE IS B2B looks to then match against the relevant partnership. My problem is this does not go to enough granularity for me to distinguish uniqueness for the second partnership I need to create.
    The problem is the "Association assigned code" field in the UNH for EDIFACT messages is not catered for anywhere in the partnership details area. This means then that whilst my existing partnership deals with Simplified Billing Claim MEDRUC's which is Association assigned code = SBC20, I can't create an EDI to Application partnership for PARTNERA and PARTNER B to cater for Two Way Gap Claiming MEDRUC's which are Association assigned code = TWC10, ie the two messages are D97B MEDRUC type messages only distinguished from each other by this Association assigned code.
    Any ideas how can I then create a unique EDI to Application partnership for this TWC10 MEDRUC message?
    What I am thinking I will have to do is make this second partnership Application to Application and create a custom service to wrap the MEDRUC message with a HREC/TREC and use the parameters in the HREC to dictate the DocType rather than use the UNB/UNH segments in the MEDRUC?

    Hmmm. It looks like way back when the decision was made on how specific the keys had to be, they didn't get quite specific enough for your case. I'm not super experienced with EDIFACT but I'll throw out some suggestions based on my HREC and X12 knowledge.
    A. Could you handle both instnaces through the same partnership, but alter the map to create unique outputs based on the two different types? At least of the cards would need to be handled through Route, but you could have that picked up by a simple Outprep / Gateway Service list that put the data where you wanted it.
    B. Before Parse, run a custom service that is capable of inspecting for which type of data it is, then modify one of the key fields in place to find the Second partnership. Really getting adventurous, maybe you could alter keys in the UNG to make the distinction. This assumes that you don't have both types of documents in the same interchange.
    C. Your idea may be workable. Can you give some more detail on the make-up of the Service list and the destination/processing of the two differnt types of MEDRUC?
    Thanks.

  • How can you create a spry menu bar with no background colour?

    How can you create the first level of a spry menu bar to have no colour? I have a coloured background right now and the colour matches when you load the site in Internet explorer but does not match in Firefox. Any suggestions are welcomed on how to fix this.
    Thanks!
    HK

    Here is the site:
    http://partnersnaturally.ca/
    I am learning with code, (obviously) so any feedback would be nice. I use dreamweaver CS4, but when I originally designed the site it was in a much older version of dreamweaver. I wonder if that could also be a cause. (besides human error)
    Thanks again,
    HK

  • Can we create the T-Code for a maintenace view

    Hi All,
    I have a table for which i create a maintence view . Now we want to create the Transaction code for that.Can it possible..?  if yes Plz help me .its very urgent .
    Thanks!
    Vipin Kumar

    Use TC SE93.
    Select option Create TC with Parameter.
    Enter TCode.
    In it maintain TC as SM30
    Click on Skip first screen
    Maintain Default Values as
    VIEWNAME = <View name>
    UPDATE = 'X'

  • How can I create a file in iMovie with a lengthy audio file, but only 1 picture?

    Let me state first off that I'm a blind user using the Voiceover screen-reader in OS X.
    Now, I want to upload some audio to Youtube, but they do not allow simple MP3 files. As such, I want to create a file in iMovie with my audio and 1 picture to use as a visual. Within iMovie, I add my audio file, select a picture, but when I publish, the audio is cut off after only a few seconds. Can someone please explain how I can fix this issue so my entire audio clip will play?

    iMovie is a visual medium, so you need to make the duration of your photo at least as long as your voiceover track. You should be able to double click on your photo and then enter a duration.
    See iMovie Help at this link.
    http://help.apple.com/imovie/#mov3a883915
    An MP3 file may work for you, but for best results, use a WAV or AIFF file (uncompressed). You can convert MP3 to AIFF in iTunes. Let me know if you need instructions.

  • Can you create report using report painter with Tcodes:FAGLL03,FCHN

    Hi Experts,
    1.I want to create report using report painter by using tcodes FAGLL03,FCHN.Can i create with report painter?
    2.i never used report painter can anyone provide report painter pdf for ecc6.0
    3.can any oneguide me how to develop report in report painter by using this tcodes.
    4.If not possible can i do with report writer?
    Regards,
    naresh.
    Moderator: Don't mix report painter with the TCodes wyou mentioned; there is no link between them. Regarding Report Painter - search SDN. Respect the rules and don't cross-post: you asked the same unclear question in several forums!

    cross posted
    Edited by: nareshvarma on Jul 19, 2010 9:11 AM

  • Can we create pl/sql code over database link?

    Hi All,
    We are using Oracle 9i database.
    I want to know if we can create or modify pl/sql code (procedue, package, etc) over the database link? That means - can we create a procedure in remote database using the db link?
    Thanks,
    Dnyanesh

    yes, I can connect to the remote database directly and create/modify the packages.
    But I want the users not to create them using the db link.
    Is there any way to create the pl/sql package over database link?
    Thanks,
    Dnyanesh

  • Can I create a fade from black with Media Encoder?

    I am having a problem with Adobe DPS making  my videos jump up (shift up a bit) in the first few seconds of the video. As a workaround I want to create a fade-from-black effect to hide the first seconds of the video. Can I create a fade in Media Encoder?

    Digital Publishing Suite
    Jim Simon wrote:
    Adobe DPS

  • Can´t create new Version from Image with meta/adjustment?

    I have some Images (.tiffs) which have Metadata/Adjustments but I can´t create a new Version from them.
    Any idea what to do??
    thanks appreciate your help!
    r

    'weeks of work'. that's far too much to just let go of. so...
    (re-reading your original message...)
    'capturing' means simply importing, right?
    but you've made adjustments to the images after import?
    and you've added keywords/IPTC/metadata to the images after import?
    I'd try:
    A. split the tiff project/s into smaller projects (100 images or so) if you haven't already done so. (this'll take a while because Aperture slows down significantly when master images are moved around)
    B. export the projects.
    C. delete the projects from inside Aperture. there should be none of your 'problematic' tiff images remaining in the library.
    D. relaunch Aperture and rebuild the library.
    E. import the projects one at a time, rebuilding the library after each import in case there is something in the project's data files that needs fixing.
    F. try to do what you want to do with the images in the project.
    if everything works ok, then import the next project and repeat steps E and F.

Maybe you are looking for

  • Shared Variable VI development on machine other than server

    I'm about to do my first shared variable code, I read the white paper http://www.ni.com/white-paper/4679/en Something that isn't immediately clear to me is the expected work flow in actually creating ALL the VIs using the shared variables.  I tried c

  • Trying to image a Dell Latitude D630

    I am trying to image a Dell Latitude D630 laptop using PXE. It is set to PXE boot in the BIOS. I select Maint Mode when the imaging screen comes up. Output starts running on the screen as normal then all the sudden the screen goes black and nothing e

  • Playbook force safe search or block content for kids

    I just picked up a Playbook on sale aqnd am pretty happy with it. It's pretty lame on being able to adjust anything though. I have an 11 year old that sometimes likes to play with it, but of course Google and YouTube provide ALL SORTS of links and su

  • HT2305 Apple Mobile Device link for a PC.

    Hello everyone. Can someone direct me to a link to save the apple mobile device download on a flash drive to put on a pc so i can use my iphone as a internet. No internet unsecure access in this building. Thanks.

  • Need to update from Mac OSX 10.2.8...

    I know, it's ancient... can I not just upgrade/update to v10.3.9 (mostly care so I can use an iPod w/iTunes)? Do I have to buy v10.3 (is this Panther or something?). Could this old OS be the reason I have such terrible luck with the internet (connect