Reputation: 4753
I am looking into compilers and I was wondering if it is possible to compile both C# and C++ files from a Java application (e.g. to compile Java from a Java application, you can use the JavaCompiler API). I have looked online for this, but all I can find is ways to compile Java files from C# and C++ and not the other way around.
If so, what API's can I use for this?
Upvotes: 0
Views: 359
Reputation: 316
If you know the system commands for compiling and executing .cpp files (I don't know much about C#), you might want to check out this. It details how to execute system commands from a Java program. Pass the system commands for compiling the required file in Runtime.getRuntime().exec()
.
Upvotes: 5
Reputation: 100527
For C# in Windows: compiler (csc.exe) is part of .Net install on Windows and can be found at well known location (like %windir%\Microsoft.NET\Framework\v3.5
for .Net 3.5). The same place also contains MSBuild.exe that can build project files (*.csproj).
Your code may need to provide locations for referenced libraries if using Csc.exe to compile individual files.
Upvotes: 0
Reputation: 1219
Consider learning how to call ant from Java code and using something like this ant enhancement.
Disclaimer: I don't know anything about this product, but found it by searching for "can ant build c++?"
Upvotes: 0