On the one hand, your existing check for an existing process looks a bit scary, but if it works so be it; although I'd ask what happens if the Java is started with another argument count?
Meanwhile, since you're trying to reuse code that works in one situation and doesn't seem to in a seemingly similar one, I'd suggest you break your existing variable down and observe it's various pipeline steps left to right to get familiar with what it's doing. You might notice that one of the columns involved with the ps command reflects the Start Time and/or Date. You might also note that your second scenario is not carrying all that many parameters, and misses the 11th one that the Java job is using.
This approach will allow you to fine tune the specifics of the scenario that you're checking...but it will also help you to get familiar with the code you're trying to use...re-use.