Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

problems with createJVM

Thread view: 
Josh Falter - 09 Jan 2006 15:54 GMT
I'm not sure if this should be posted here or in the C++ forums, but
I'm figuring it is more likely that there is someone else here who has
run into similar issues before.

I am using the invocation api to access my java classes from a COM
based C++ application.

I know that my routines for creating the JVM are correct.  When I run
it using a tester app on my machine, it works perfectly.

When I add it to the full flavored C++ application, I run into 1 of 2
problems depending on where I try to create the JVM.

If I call out to my start JVM function to get a handle to the JNIEnv
from the preInitialize method of the COM class, which is where the COM
classes are registered and constructed, all parts of the java
application and jni connection work 100% correctly.  The problem is
that this messes up the onscreen graphics of one of the other COM
classes to the point where they don't function and the machine gives me
a Win32 error code of 6, which is an end of file error (no idea why
even after looking at the code and trying to watch it with utilities)

Since I havent been able to fix the graphics problem, I have tried
pulling the start JVM function into the event handler function where
the JNI connection is actually used.  When I use it there, the exact
same JNI_CreateJavaVM function returns a null value 100% of the time
for the JNIEnv.

I haven't been able to find much information on what causes the
JNI_CreateJavaVM to fail, so any suggestions would be appreciated, nor
do I understand the process that it goes through under the hood to
create the environment, for example how the threading of it works.  Is
it taking over whatever the current thread in the c++ code is when I
create it?

I would post a SSCCE, but I don't believe that the problem is in my
code, rather I think it is in my lack of understanding of all the
things that are going on behind the scenes.

Any insight would be greatly appreciated.

Best,
Josh Falter
Chris Uppal - 10 Jan 2006 10:49 GMT
> If I call out to my start JVM function to get a handle to the JNIEnv
> from the preInitialize method of the COM class, which is where the COM
> classes are registered and constructed, all parts of the java
> application and jni connection work 100% correctly.  The problem is
> that this messes up the onscreen graphics of one of the other COM
> classes to the point where they don't function

That sounds as if you have an old-fashioned, pointer-related bug somewhere.
I.e. not a problem with the way you are using COM or JNI as such.

That's not to say that you might not have such problems /too/.  In fact I would
be very wary of mixing COM and JNI since both have very specific laws about how
they are used (mostly to do with threads) and I don't know nearly enough about
COM to be sure that I was doing things "right" even if I was reasonably sure I
wasn't abusing JNI.

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.