Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Variable Exchange Java <-> C++

Reply
Thread Tools

Variable Exchange Java <-> C++

 
 
ToSam
Guest
Posts: n/a
 
      02-02-2005
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?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      02-02-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MCSE 2003 w/Exchange or MCITP 2008 w/Exchange Juan MCITP 3 06-19-2009 07:29 PM
Cannot send mail from Exchange 2007 mailbox to Exchange 2003 mailb =?Utf-8?B?am9zdWU=?= MCSE 3 08-15-2007 12:02 PM
Exchange Links < Western Cartoon Cards > Exchange Links www.westerncartooncards.ca HTML 2 07-12-2004 07:59 PM
Exchange 5.5 with Exchange 2000 Cluster problem Jose Luis Microsoft Certification 0 02-13-2004 10:23 AM
help: My exchange lost M: and exchange can not start winman MCSE 9 07-30-2003 04:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57