Sounds like you won't have a compiler on a target system, right? So compile your C++ code beforehand (for multiple platforms, if you need) and either execute it via either
Runtime.getRuntime().exec(...)
or via
ProcessBuilder API. If that's a dynamic library, make JNI wrapper and use it instead.
Unfortunately, it's quite hard to offer anything specific from your broad definition of the task.