I am writing a VC++ program that has to fetch Java source code from a file, compile and execute it at runtime, and return the result objects back to C++. Does anyone have a sample code for this or any suggestions?
search in the internet for some Java Parsers. After that use JNI to invoke classes. I don't know why do you need that. Would you like to create a debugger?
Thanks. No, the thing is this: For my company I have to write a C++ test program that launches a Java compiler to compile some given code (in a file). After that, the compiled Java code must be executed and return some result objects to C++. So I have to somehow embed a Java compiler and invoke it within C++ code. Do you have any suggestions?
you don't have to embed any java compilers in the application. You may just use system("javac *.java") to compile java files. Or instead of system you may use exec* family functions, or CreateProcess or any function for invoking any operation system commands to launch java compiller. After that use JNI to invoke the main function from some class what contain it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.