473,915 Members | 5,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic class question

joe
I have the following header file generated by Java JNI's header file
generator (see bottom).

Obviously I will write a source file which will provide an implementation of
these methods.

I have a few questions regarding this:

1) Where is the class name defined? Is this a C++ class? It says "class
TestAPIMsg" in a generated comment but I can't see where this is set in the
header file.

2) How do I set global variables in this class (baring in mind it tells me
not to edit the header file)?

3) How do I add additional methods to this class i.e. ones not set in the
header file (again baring in mind I can't edit the header)?
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestAPIMsg */

#ifndef _Included_TestA PIMsg
#define _Included_TestA PIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _IncomingMessag e
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: DoConnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoConnect
(JNIEnv *, jobject);

/*
* Class: TestAPIMsg
* Method: DoDisconnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoDisconnect
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

Mar 4 '06 #1
4 1929
TB
joe skrev:
I have the following header file generated by Java JNI's header file
generator (see bottom).

Obviously I will write a source file which will provide an implementation of
these methods.

I have a few questions regarding this:

1) Where is the class name defined? Is this a C++ class? It says "class
TestAPIMsg" in a generated comment but I can't see where this is set in the
header file.
The generated functions combined form a class interface even though
there isn't a formal class definition available. Most likely "jobject"
is a pointer to a structure of some sort that contains necessary
instance variables.

2) How do I set global variables in this class (baring in mind it tells me
not to edit the header file)?
What "global variables in this class"?

3) How do I add additional methods to this class i.e. ones not set in the
header file (again baring in mind I can't edit the header)?

Just add them.

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestAPIMsg */

#ifndef _Included_TestA PIMsg
#define _Included_TestA PIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _IncomingMessag e
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: DoConnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoConnect
(JNIEnv *, jobject);

/*
* Class: TestAPIMsg
* Method: DoDisconnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoDisconnect
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif


--
TB @ SWEDEN
Mar 4 '06 #2
On Sat, 04 Mar 2006 13:22:19 GMT, "joe" <jo*@gmailNOSPA M.com> wrote:
I have the following header file generated by Java JNI's header file
generator (see bottom).

Obviously I will write a source file which will provide an implementation of
these methods.

I have a few questions regarding this:

1) Where is the class name defined? Is this a C++ class? It says "class
TestAPIMsg" in a generated comment but I can't see where this is set in the
header file.
It appears to be a Java class. The header is there so that a C or C++
program can call exported methods in the Java unit containing the
implementation of TestAPIMsg.
2) How do I set global variables in this class (baring in mind it tells me
not to edit the header file)?
If it is a Java class, you need to edit the Java program's source code
so that the methods to set them are exported, then regenerate the
header file.
3) How do I add additional methods to this class i.e. ones not set in the
header file (again baring in mind I can't edit the header)?
Again, in the Java program's source code, then regenerate the header.
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestAPIMsg */

#ifndef _Included_TestA PIMsg
#define _Included_TestA PIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _IncomingMessag e
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: DoConnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoConnect
(JNIEnv *, jobject);

/*
* Class: TestAPIMsg
* Method: DoDisconnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoDisconnect
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif


--
Bob Hairgrove
No**********@Ho me.com
Mar 4 '06 #3
* joe:
I have the following header file generated by Java JNI's header file
generator (see bottom).

Obviously I will write a source file which will provide an implementation of
these methods.
Goodie.

I have a few questions regarding this:
I have moved to after the code.

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestAPIMsg */

#ifndef _Included_TestA PIMsg
#define _Included_TestA PIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _IncomingMessag e
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: DoConnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoConnect
(JNIEnv *, jobject);

/*
* Class: TestAPIMsg
* Method: DoDisconnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoDisconnect
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif
1) Where is the class name defined?
This header file does not define a class.

Is this a C++ class?
Is what a C++ class? You have generated this header from Java source
code. Presumably you have /some/ understanding of that.

It says "class TestAPIMsg" in a generated comment but I can't see
where this is set in the header file.
What /what/ is "set"?
2) How do I set global variables in this class (baring in mind it
tells me not to edit the header file)?
In which class?

3) How do I add additional methods to this class i.e. ones not set in the header file (again baring in mind I can't edit the header)?


Which class?
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 4 '06 #4

JNI doesn't generate a class or any C++ code, only the header file. The
header file
provides the declarations of extern "C" functions which you will have to
implement in a shared library or DLL. If you implement things correctly,
your java code can load the library
at run time and call the interface functions you have written. You must
understand that
the functions in the interface are "free" functions (ie, not members of a
class), but you can
implement their functionality using classes and member functions if you
wish. The "class"
name appearing in the generated file is the original Java class which you
used to generate
the JNI interface.

For instance, in your C/C++ you will have to implement this function:
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

which might look something like:
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring)
{
// convert jstring into string object.....

cout << "Received test message.....\n" ;
}

If you want to generate a class on the C/C++ side, you will need to add more
functions to
the Java JNI interface, such as createMyClass() , destroyMyClass( ), etc.

You will not get very far unless with JNI you read the documentation for
JNI, I'd recommend getting one of the two main books on the subject, JNI is
a very complicated system, more complex than I could explain in an email.

dave


"joe" <jo*@gmailNOSPA M.com> wrote in message
news:fw******** ***********@new sfe2-win.ntli.net...
I have the following header file generated by Java JNI's header file
generator (see bottom).

Obviously I will write a source file which will provide an implementation of these methods.

I have a few questions regarding this:

1) Where is the class name defined? Is this a C++ class? It says "class
TestAPIMsg" in a generated comment but I can't see where this is set in the header file.

2) How do I set global variables in this class (baring in mind it tells me
not to edit the header file)?

3) How do I add additional methods to this class i.e. ones not set in the
header file (again baring in mind I can't edit the header)?
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestAPIMsg */

#ifndef _Included_TestA PIMsg
#define _Included_TestA PIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg _SendMessageTes t
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _IncomingMessag e
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: DoConnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoConnect
(JNIEnv *, jobject);

/*
* Class: TestAPIMsg
* Method: DoDisconnect
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg _DoDisconnect
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

Mar 4 '06 #5

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

Similar topics

1
1251
by: Bob | last post by:
Try the following code class basic { public: virtual void one()=0; }; class derived1:public basic { public:
4
2239
by: Ramesh | last post by:
hi, Let me ask some basic questions. Can anybody explain me about the following questions: 1. When we have to create sn key? Whenever we compiled Component we have to create or it is a one time process? 2. What information contained in sn key. I gone through that it is having public key. How it is using this key to intract with client. 3. When we have to run gacutil.exe file. Whenever we
5
1187
by: Paul Bromley | last post by:
I have written a similar enquiry to this newsgroup, but had no responses - hence I will rephrase it with the hope that someone will answer. I am new to using Classes, but trying hard to get the basics at the present time, and seem to be winning. Presently I am developing a Usercontrol for use in my application. To keep it simple, let me give as an example - I have 3 command buttons in the User Control. Each of these will have separate...
13
15584
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the HTTP level but as yet no fully useful answer. I too have been trying to call an apache/axis webservice which desires a username/password from my C# Client. (ie the equivalent of _call.setUsername("Myname") name from within a Java client proxy)...
5
1817
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the property '.fulladdress' to be the value that appears in the drop downs text section. How to I set that parameter to be the one shown inthe drop down
18
2414
by: Ann Scharpf via AccessMonster.com | last post by:
I am not sure which would be the best place to post this question, so I'm posing it here with Access general questions. I have reached the point many times in Word and in Access where my ignorance of VBA is a real detriment to me. I saw some posts about VBA classes with a particular vendor and the poster was advised not to take the class because of the likelihood of an unskilled trainer. My question is, would taking a Visual Basic...
4
1742
by: MikeB | last post by:
I've been all over the net with this question, I hope I've finally found a group where I can ask about Visual Basic 2005. I'm at uni and we're working with Visual Basic 2005. I have some books, - Programming Visual Basic by Balena (MS Press) and - Visual Basic 2005 by Willis (WROX), but they don't go into the forms design aspects and describing the various controls at all. What bookscan I get that will cover that?
14
1863
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems logical to have them all inherit from a base class that defines those, but this doesn't work: import tok class code: def __init__( self, start, stop ):
9
1615
by: Peskov Dmitry | last post by:
It is a very basic question.Surely i got something wrong in my basic understanding. //Contents of file1.cpp using namespace std; #include <iostream> template <typename T> class my_stack;
3
1949
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee objects that I can iterate through relatively easily. I've included code at the bottom of this message. I can pretty easily iterate through my employee objects like so: Dim theEmployees As Employees = New Employees
0
9883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11359
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7259
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5944
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.