Variable Exchange Java <-> C++

T

ToSam

In my C++ program I execute a java.class file via the CreateProcess
function. In details:

// define a pointer to directory with Main.class file
char * pExecute = "java Main";

// create a java interpreter process
if( !CreateProcess( NULL, // No module name (use command line).
pExecute, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
CREATE_NEW_CONSOLE,
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
TRACE( "CreateProcess for Execute failed (%d).\n", GetLastError() );
return;
}

The java-class Main.class is the compiled class of the code

public class Main {

public Main() {
}

public static void main(String[] args) {
try{

MCDVersion pMCDVersion = new MCDVersion();
int minor = pMCDVersion.getMinor();

} catch (com.inzoom.comjni.ComJniException e){
System.err.println("Exception: "+e.getMessage());
}

}
}

Obviously, Main.class returns an integer int minor. The big question
is this: How can i pass this integer back to my C++ program to make it
available there? I shall not change the Java code. Any ideas?
 
V

Victor Bazarov

ToSam said:
In my C++ program I execute a java.class file via the CreateProcess
function. In details:

[...]

Obviously, Main.class returns an integer int minor. The big question
is this: How can i pass this integer back to my C++ program to make it
available there? I shall not change the Java code. Any ideas?

Ask in a Java newsgroup. C++ defines no mean of cross-language coding
except for C. Java OTOH has JNI, which is specifically designed to be
used for linking to other languages.

V
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top