You can use the tee command to both append your output and keep writing to stdout:

RESULT_STDOUT=$($java classname | tee -a Mylog.txt)

Here, the -a asks tee to append to Mylog.txt, if possible.

I'm not sure why you need the true there, so I excluded that. The main problem here is how to preserve the error log. If you do 2>&1 it will become part of Mylog.txt but also of the result. If storing the error log in a separate file is sufficient for you, you can redirect it with