Java from VC++

T

ToSam

I am writing a VC++ program that has to fetch a Java source file,
compile it with a Java compiler, execute it at runtime, and return the
result objects back to VC++. Do you know of any sample codes to
illustrate how that works, or any suggestions?
 
M

msalters

ToSam said:
I am writing a VC++ program that has to fetch a Java source file,
compile it with a Java compiler, execute it at runtime, and return the
result objects back to VC++. Do you know of any sample codes to
illustrate how that works, or any suggestions?

There are some things that you can actually do in C++ (fetch a file,
probably - what exactly do you want to do?), execute a program
( std::system("path/to/javac.compiler") or std::exec* functions ),
and IIRC the Java file that is produced can be run again using
a similar std::system command.

I'm not sure what you mean with the "result objects". The closest
thing to a result object in C++ is the single int returned from
int main( ). But I could imagine the Java program producing an
output file. You could read that back in C++. In fact, since Java
sources are just text, and C++ can manipulate text, you could also
modify the Java source text before you compile it, such that the
output objects are stored to a file.

HTH,
Michiel Salters
 
M

Mike Wahler

msalters said:
There are some things that you can actually do in C++ (fetch a file,
probably - what exactly do you want to do?), execute a program
( std::system("path/to/javac.compiler") or
std::exec* functions ),

There are no functions in the C++ standard library
whose names begin with 'exec'.

-Mike
 

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
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top