C++ and Java in a large application

U

Ulf Reiman

I have a large application environment built up in Java many java
classes, but now a have get code in C++ and wonder how a can get Java
and C++ to work together, can anyone give me some suggestion.

Regards
Ulf Reiman
 
G

Gordon Beaton

I have a large application environment built up in Java many java
classes, but now a have get code in C++ and wonder how a can get
Java and C++ to work together, can anyone give me some suggestion.

"work together" can mean many things. Be much more specific.

From Java you can use Runtime.exec() to run programs written in any
language, and similar mechanisms exist other languages that let you
run Java applications.

A Java application can use a Socket to connect to a server written in
any language (including C++), or use a ServerSocket to accept
connections from any client.

For a tighter coupling, JNI lets you invoke C or C++ methods directly
from Java, and vice versa:

http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html
http://java.sun.com/docs/books/jni/

/gordon
 
U

Ulf Reiman

Thank you for your answer. So if you have functions in C++ classes that
uses functions in JAVA classes, is that possibly to do that JNI
/Ulf
 
G

Gordon Beaton

Thank you for your answer. So if you have functions in C++ classes
that uses functions in JAVA classes, is that possibly to do that JNI

Yes.

/gordon
 
U

Ulf Reiman

Is it possiby to use same memory space for varibles or do a need to
use set and get funtions to change variables used both i C++ and Java

/Ulf
 
G

Gordon Beaton

Is it possiby to use same memory space for varibles or do a need to
use set and get funtions to change variables used both i C++ and Java

Did you read the links I posted in my first reply?

/gordon
 
C

Chris Uppal

Ulf said:
Is it possiby to use same memory space for varibles or do a need to
use set and get funtions to change variables used both i C++ and Java

It's /much/ more complicated than that. See Sun's JNI tutorial for a start:

http://java.sun.com/docs/books/tutorial/native1.1/index.html

You'll now see why Gordon mentioned other ways of intergrating C++ and Java
programs before JNI.

If you still want to use JNI then read the JNI book. Downloadable (free) from:

http://java.sun.com/docs/books/jni/index.html

-- chris
 
U

Ulf Reiman

So as a see it (after a short look on JNI) ,the only way to have a
function in Java that uses variables in C++ code is to us JNI, it not
trivial to understand JNI, or can it be easier to use CORBA. On the
other hand, does anyone have a better solution?
 
U

Ulf Reiman

So as a see it (after a short look on JNI) ,the only way to have a
function in Java that uses variables in C++ code is to us JNI, it not
trivial to understand JNI, or can it be easier to use CORBA. On the
other hand, does anyone have a better solution?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top