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

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_TestAPIMsg
#define _Included_TestAPIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg_IncomingMessage
(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 1906
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_TestAPIMsg
#define _Included_TestAPIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg_IncomingMessage
(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*@gmailNOSPAM.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_TestAPIMsg
#define _Included_TestAPIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg_IncomingMessage
(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**********@Home.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_TestAPIMsg
#define _Included_TestAPIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg_IncomingMessage
(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_SendMessageTest
(JNIEnv *, jobject, jstring);

which might look something like:
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(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*@gmailNOSPAM.com> wrote in message
news:fw*******************@newsfe2-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_TestAPIMsg
#define _Included_TestAPIMsg
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestAPIMsg
* Method: SendMessageTest
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_TestAPIMsg_SendMessageTest
(JNIEnv *, jobject, jstring);

/*
* Class: TestAPIMsg
* Method: IncomingMessage
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_TestAPIMsg_IncomingMessage
(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
by: Bob | last post by:
Try the following code class basic { public: virtual void one()=0; }; class derived1:public basic { public:
4
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...
5
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...
13
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...
5
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...
18
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...
4
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, ...
14
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...
9
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
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.