My problem regards to compiling c++ file within java. I have tried execution of c#, it is fine.
This extract code for compiling c#
ProcessBuilder launcher = new ProcessBuilder("gmcs","HelloWorld.cs");`
However, my code for c++
ProcessBuilder launcher =new ProcessBuilder("g++", "HelloWorld.cpp -o HelloWorld");
returns error=2, No such file or directory
To indicate path I used
launcher.directory(new File(path))
in both of cases
You need to provide arguments separately:
Otherwise the whole argument string is passed as one argument to the
g++executable, andg++tries to find a file namedHelloWorld.cpp\ -o\ HelloWorld(using escaped spaces as you would on a Linux terminal).See the documentation for details on the usage.