Java is a platform independent so when you need to deliver a binary which may need to be run on different platform you may choose Java. On the other hand C++ provides higher performance as it is more close to assembly as compare to Java and in this case you may choose C++.