By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Variable Exchange Java <-> C++

P: n/a
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?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ToSam wrote:
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
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.