473,383 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Urgent Help: Multiple calls to JNI_CreateJavaVM

Hello,

I have 2 VC++ codes calling Java functions. An application loads these
VC++ dll files. When the application invokes the first VC++ dll , I
initialize and create the JVM using the JNI_CreateJavaVM(&jvm, (void**)
&env,&vm_args) funtion. This works fine and am able to perform all the
operations.
I destroy the JVM when the application is closed.

The problem arises when the application tries to load my other VC++
dll. The second initialise which also has a JNI_CreateJavaVM(&jvm,
(void**) &env,&vm_args) function fails as this returns a -1.

Is there anyway I can have both my dll functioning at the same time?

The thought of destroying JVM after every operation and not leaving it
open till the application closes crossed my mind, even though
performance will be an issue, but that also wouldnt solve the problem
because the application is multi-threaded. So when the first code is
being executed, if someone calls the second one it will fail because
the init fails. Also since it is a known bug that we cannot destroy and
create a VM in the same process, am not able to do that.

Say I make the JNI_CreateJavaVM() in the first dll and I always make
sure that this is initialized first, is there anyway I can do a
(jvm)->AttachThread() to the first one that gets created? and also get
the JNIenv * value from that dll?

Any help would be appreciated. Thanks

Ham

Feb 10 '06 #1
2 3654
mu*************@gmail.com wrote:
I have 2 VC++ codes calling Java functions. An application loads these
VC++ dll files. When the application invokes the first VC++ dll , [...]

The problem arises when the application tries to load my other VC++
dll. [...]

Is there anyway I can have both my dll functioning at the same time?
[...]


This is not the right place to post your platform-specific question.
Please read the FAQ 5.9 for suggestions which newsgroups are more
appropriate.

V
--
Please remove capital As from my address when replying by mail
Feb 10 '06 #2
On 10 Feb 2006 11:21:13 -0800, mu*************@gmail.com wrote:
I have 2 VC++ codes calling Java functions. An application loads these
VC++ dll files. When the application invokes the first VC++ dll , I
initialize and create the JVM using the JNI_CreateJavaVM(&jvm, (void**)
&env,&vm_args) funtion. This works fine and am able to perform all the
operations. I destroy the JVM when the application is closed.

The problem arises when the application tries to load my other VC++
dll. The second initialise which also has a JNI_CreateJavaVM(&jvm,
(void**) &env,&vm_args) function fails as this returns a -1.

Is there anyway I can have both my dll functioning at the same time?


Your question is very specific and platform dependent. The gerneral
question is: How do you initialize something once and only once? The
usual answer: Use a Singleton.

Best wishes,
Roland Pibinger

Feb 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dimitri | last post by:
PLEASE HELP,I HAVE A DATABSE WITH MULTIPLE RECORDS AS OUTLINED BELOW EMP NO LEVEL NEXTINCREASE WAGETYPE UNIT 1000 1 0 1000 1000 1 0 1002 ...
4
by: Chronologic | last post by:
All, I have an issue I would like some expert help on. I understand, or so I believe, that C# does not support the concept of a "compile time macro". At least not in the sense I'm looking...
1
by: RNEELY | last post by:
I am trying use CLR from an old VC6 MFC app that was ported to the VC7 compiler. Initially the app worked fine. However, after I enabled /clr in the project settings and ran the app, all calls...
0
by: Björn Bengtsson | last post by:
Hello! I have an urgent problem concerning ASP.NET, ADO.NET, SQL Server, XML and the TreeView control. I have two tables; one describing the products and one describing their relationships. A...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
13
by: Niyazi | last post by:
Hi I have a report that I have to run it monthly in my machine. My code in VB.NET and I access AS400 to get data, anaysie it and send into pre formated Excel sheet. The data consist of 9000...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.