473,881 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c++ calling java calling c++ ...

Hi,

i'm currently working on a plugin for Adobe InDesign and i have some
problems with that. I'm not really a c++ guru, maybe somebody here has
an idea how to solve this.

The plugin is written in C++ and it's calling a java application. This
application displays a window and pushing a button is calling back the
c++-plugin again.

// The plugin class. CActionComponen t is part of the InDesign SDK
class MyJNIComponent : public CActionComponen t {
public:
...
static void onCreateDocumen t();
...
private:
...
void registerCallbac ks();
...
}

// this is called from the java application
JNIEXPORT void JNICALL Java_createDocu ment(JNIEnv *e, jobject o);

// this is called from Java_createDocu ment()
void MyJNIComponent: :onCreateDocume nt() {
...
// Here i'm using SDK-methods and functions to create and display a
document.
// And here is the problem - i get an assertion from the SDK.
// The code to create the document is ok, i used this code before
and i can
// call this method from inside the plugin without assertion
...
}

// Register Callback from the Java Application back to the Plugin
void MyJNIComponent: :registerCallba cks() {
jint res;
JNINativeMethod nm;

// if this method is called in the java application ..
CJavaClassInsta nce layoutSystemToo lBox("path/to/my/java/class");
nm.name="create Document";
nm.signature="( )V";

// .. call this function in the plugin
nm.fnPtr=Java_c reateDocument;

res=CJavaVM::en v()->RegisterNative s(layoutSystemT oolBox.getClass Definition(),&n m,1);
if (res!=0) {
CJavaVM::report Error("Can't find the Java_createDocu ment
method.");
return ;
}
}

// this function is called from java
JNIEXPORT void JNICALL Java_createDocu ment(JNIEnv *e, jobject o){
CJavaVM::env()->ExceptionClear ();
// calling method in plugin class
MyJNIComponent: :onCreateDocume nt();
}

I think the problem is, that Java_createDocu ment() is not part of the
MyJNIComponent class and when i'm calling
MyJNIComponent: :onCreateDocume nt() from Java_createDocu ment() some
variables are not proper initialized.
And i don't know how to make Java_createDocu ment() part of the class.
Or if there is another way to solve this?

Thanks for any suggestions.
Aug 12 '05 #1
7 6611
I don't know but have you tried communicating via socket?

Ben
Aug 12 '05 #2
>I don't know but have you tried communicating via socket?
No. It's an idea but we have to change everything. At the moment the
java application works standalone and we're using some code and
dialogs for the plugin and for an extension for QuarkXPress.
Aug 12 '05 #3
comp.lang.c++

The name implies questions concerning the C++ language. Questions about
JNI and interaction with C++ should go to Java newsgroup because it
relates to JNI. Not C++.

-vijai.

Aug 13 '05 #4
* Klaus Friese <kfriese at dataplan punkt de>:
// And here is the problem - i get an assertion from the SDK.
// The code to create the document is ok, i used this code before
// and i can call this method from inside the plugin without
// assertion
...
}


So, the problem is in the code you haven't shown.

Anyway, the title is probably wrong: it seems your problem is "Java calling
C++ calling Java", or "Java calling C++ calling some Adobe API".

I do not think at all that the general area is off-topic, because such
integration is what C++ is often used for. Many questions in that area
would most be accepted in [clc++m]. However, it seems that what you have is
not a problem related to C++ usage in general, or the language, but rather
it seems to be a bug in your code, which would make the question -- with
relevant code included! -- more appropriate for e.g. [comp.programmin g].

But in general, if you can get rid of the Java part, do that: pure C++.

And in general, your problem description seems to be to vague to say more.

--
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?
Aug 13 '05 #5
On Sat, 13 Aug 2005 04:11:51 GMT, al***@start.no (Alf P. Steinbach)
wrote:
* Klaus Friese <kfriese at dataplan punkt de>:
// And here is the problem - i get an assertion from the SDK.
// The code to create the document is ok, i used this code before
// and i can call this method from inside the plugin without
// assertion
...
}
So, the problem is in the code you haven't shown.

Anyway, the title is probably wrong: it seems your problem is "Java calling
C++ calling Java", or "Java calling C++ calling some Adobe API". Java calling c++ is the standard way to use JNI, but i have the other
direction here.
We have an large application written in java and now we are writing
c++ code that uses parts of the java application. So people can use
the main application and they can use InDesign or XPress and they see
the same windows and dialogs.
I do not think at all that the general area is off-topic, because such
integration is what C++ is often used for. Many questions in that area
would most be accepted in [clc++m].

I can try it in clc++m tomorrow (i'm writing from my home account at
the moment). I also tried to find help in the Adobe User Forums, but
calling Java from the Plugin is not very commom.

---
Mail-Antworten bitte an klaus punkt friese at hamburg punkt de
Die andere Adresse ist nur ein Spam-Collector.
Aug 14 '05 #6
An easier route would be to use J-Integra for COM. It is a
bi-directional Java/COM interop bridge which allows C++ to talk to Java
and vice-versa. It supports callbacks, events, etc. It even has a high
performance native mode (i.e. JNI) built in. Have a look...

http://j-integra.intrinsyc.com/

Shane Sauer
J-Integra Interoperabilit y Solutions
http://j-integra.intrinsyc.com/
When Web Services are not enough

Aug 15 '05 #7
On Sun, 14 Aug 2005 10:38:15 +0200, Klaus Friese <klaus punkte friese
at hamburg punkt de> wrote:
Java calling c++ is the standard way to use JNI, but i have the other
direction here.
No, JNI is both directions, see e.g.
http://java.sun.com/docs/books/jni/html/jniTOC.html
http://www.haertfelder.com/jni.html
http://www.jguru.com/faq/topicindex.jsp?topic=JNI
We have an large application written in java and now we are writing
c++ code that uses parts of the java application. So people can use
the main application and they can use InDesign or XPress and they see
the same windows and dialogs.


I've used JNI to call Java from C++ but I wouldn't do it again. The
JNI C++-to-Java interface is _very_ ugly and clumsy (but not the
Java-to-C++ interface, guess why). Moreover, a minimal Swing
application consumes at least 40 MB (up to 80MB or more) and you
cannot unload Java once it has been loaded with the shared library.
I'd rather communicate by socket (or COM?) with the Java application
or use a commercial product. You have been warned!!

Best wishes,
Roland Pibinger
Aug 15 '05 #8

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

Similar topics

9
3776
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
2
5948
by: Radha News | last post by:
Hi, I am looking for reference books/tools/code samples for calling java objects/methods from COM/C++ classes. I am reasonably familiar with JNI. If you have used JNI, please let me know of your experiences and things that I need to watch out. I have used JNI 1.1 and it had several bugs and limitations especially for C++ calling Java. Is the newer version of JNI (version 1.4) any better?
1
6747
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name this WebService1. (using Apache Axis 1.1) Scenario 1: -----------
7
4995
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
3
5088
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the data. my client code creates an XML document class, fills the data using standard xml dom...
6
8972
by: Sascha Schmidt | last post by:
Hi again! Well, the first part of my "mission" (calling remoting objects from a webservice) is solved. But there's another part: Calling this C#-Webservice from a java client. Is this a difficult task? Or is this quite easy, like just a few lines of source and using some of the packages from apache.org? Has anybody done this before and will like to tell me about his/her experiences?
4
12969
by: simon | last post by:
hello, may have a need shortly to call a java class from a vb.net web app. basically the java class would serve as an email creation/sending function. i realize this all could be done in .net, but i'm just curious as to what needs to be set up to make a call such as this. i realize you can call a java function from sql server and was wondering if wrapping the call to java from a proc would be an easy way to go. preferably i'd like to...
1
2984
by: amgupta8 | last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2. Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well). This is the original exception that I got before I tried any code modifications: java.io.IOException: invalid offset/length at...
4
3595
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in the...
0
9776
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
11096
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...
0
10716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10400
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...
0
9552
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7108
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
5780
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
4597
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
3223
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.