The issue is that transactions read from the block API need to be processed before being able to compute their transaction ID.
See Calculating Transaction ID - #2 by fabrice
You can see some Go code for that there: indexer/util.go at a63f591c59bc64ea870c742b0197c072003ed0e6 · algorand/indexer · GitHub
You can adapt it to Java.
But the easiest solution is really to use an indexer.
PS: I’ve fixed indentation in code and wrote it between ``` to make it easier to read.