473,396 Members | 1,724 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,396 software developers and data experts.

header file to include java classes?

Hi,
I'm working on a Migration project (Forte to JAVA).

The forte client had a C++ dll which used to call one more FORTE dll
for a complex database calculations.

Now all the forte code has been migrated to JAVA except this piece of
code where C++ dll calls Forte DLL.
I'm using JNI to call the Java classes from C++. Some of the methods
in C++ has the header files where the signature has reference to the
Forte Classes (Which are now Java Classes).

How do I change the header files to include Java classes in the
signature?

(I couldnt find a strong reference for this, but i assume that for all
the classes in Java I'll need to create the .h file using javah
utility.
Here is the Sample in one of the C++ header files:

qqhConnectionHandleClass * m_ForteConnHandle; //
qqhConnectionHandleClass was Forte class which is now a
ConnectionHandleClass in Java.
HWND m_hwndParent;
int m_autocommit;
StatementHandle * m_StmtHandles;
.....

Almost all the signatures in the header files of C++, have references
to Forte / Java classes.

Do I need to use javah and create a header file for the classes and
then include in the C++ header file?
In the implementation class (C++) just including jni.h solves my
problem as it is enough to create the jvm and loading classes/
executing methods..
Any help is appreicated.

Newbie in C++ :)

Thanks,
Swapnil.

Dec 19 '07 #1
1 2763
On Dec 19, 4:22 pm, Swapnil Kale <swapnil.k...@gmail.comwrote:
Now How do I refer this converted Java Class in the C++ header.

How do I tell the C++ header where to look for the Java classs?
I believe you can't use the whole Java class in C++ through JNI. JNI
is used to access and call member functions. The 'native' Java keyword
refers to functions that run outside the JVM, but not to classes

If you use javah on a Java member function (well, on a .java file but
you get what i mean), you get a C++ header with also a parameter that
is a handle to that Java object. You can use that handle to get access
to other variables of that class and stuff like that through the JNI
API. You also have similar access to objects that are parameters to
the function call. But you don't get a full class in the C++ header.

Why do you need the full Java Class in C++? If, for example, you are
trying to create an object through its Java class in C++, i doubt you
would be able to do it directly. JNI might provide functionality for
something like that, though, but i didn't need it so I didn't
research :) However I don't recall seeing anything like that, either.
However, you could create that Java object through a Java factory,
that returns an instance of that Java object, that C++ can have access
to.

Are you trying to have a C++ executable that creates the JVM? In that
case, from what I understand, it might be better to have a Java jar
that loads a C++ library that only deals with the dll.

Think of JNI as a bridge between functions, not classes. Besides,
classes are a compile-time construct and objects are a run-time one.
This communication is done dynamically, so you have to deal with
objects.

Forgive my horrible terminology, I was in a hurry :)
Dec 19 '07 #2

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

Similar topics

21
by: Hattuari | last post by:
I'm learning C++ after having spent several years in the computer industry doing both system administration and engineering. I've written code in Perl, Bash, Pascal, Ada, C, Mathematica (hundreds...
11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
4
by: rajkirangrandhi | last post by:
Hi, I have several classes written in Java that I am trying to convert into C++. They are fairly simple classes, no gui stuff etc, just some math routines. I was able to do it without any problem....
15
by: Kannan Goundan | last post by:
Maintaining a C++ header file can be painful. I want a way to automatically generate header files from the implementation file. Does anybody know of a program that does this? If not, I'd like...
4
by: Adam Clauss | last post by:
OK, lets say I have a C# Windows application. In it is a a series of namespaces, all rooted for a certain namespace A. For ex, the "using" directives would read something like: using A; using...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: Bruce | last post by:
I have seen sample code that is implemented in the .h header file ("java style") and I have seen samples where the code was implemented in the ..CPP file. Which is correct? What is the best...
14
by: Jess | last post by:
Hello, I was told that if I have a template class or template function, then the definitions must be put into the header file where I put the declarations. On the other hand, it is generally...
2
by: abujarour | last post by:
Hi, I am working on a c++ project. I want to define my own classes. I define each class in a separate header file, and define the body of its methods in another source cpp file. For example:...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.