Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI_CreateJavaVM  RSS feed

 
Dave Bee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access java classes from Objective C/C++. My attempts to create the JVM using functions found in the jni.h file have so far returned error codes < 0 which indicates an error. I have had a -3 error which I think means a version problem. I think that has been fixed, but now I have the -1 error and have found no corresponding meaning for that one. One other question I have is: can I create an object in Objective C based on a java class and invoke all the functions in that class? AND if I create more than one object in Objective C that is based on a java class how will I be able to keep the instances straight in the JVM? (if that makes any sense). If one if these objects created in ObjC based on a java class either has a return value of "object" or needs to pass a parameter that is of type "object"(non primitive data type) how is that handled?
Am I making this harder than it is? if so please enlighten me.
Thanks in advance
DB
 
Dave Bee
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer to my own question and due to the fact the one of the moderators has been riding me and riding me to post my solution I will explain what happened in my case. I was using the MS visual studio debugger to step thru the code I wrote to try to determine what was going on. When one goes into the tools/options menu directories tab and sets the directories for the various includes, libraries and executables you are setting things up for your debug environment. Running code from the DOS command line uses the global environmental variables. This proved to explain at least part of the problem. During various debugging sessions the jvm.dll was moved(by me) to the directory where my application existed in an attempt to make the code work. This was a mistake. The proper way to handle things in the debug environ was to make a path for the executables like this: C:\Program Files\Java\j2re1.4.2_03\bin\client (the jvm.dll exists there) This path should have been created in the tools/options directories tab/executables dropdown.
Once I did that and removed the jvm.dll from my application directory the debugger used that path info to find the proper jvm.dll AND most importantly it found it's LOCATION. Apparently it's location is used sort of as a navigational reference because other .dlls need to be navigated to. to create the JVM.
I hope this helps others... I am currently working on a problem I am having with the FindClass() function. It's not finding classes I know exist. If anyone can offer insight here I would appreciate it and if I find the answer first I'll publish my answer here.
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting your solution to the CreateJavaVM problem. Worked like a charm.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!