This works for me. I did not test using java, but I tested using sleep :
victor@vz :~$ exec -a minecraft sleep 1m & [1] 3858 victor@vz :~$ ps x | grep mine 3858 pts/2 S 0:00 minecraft 1m 3860 pts/2 S+ 0:00 grep --color=auto mine victor@vz :~$
However, this is apparently just a cosmetic change, as far as I can tell from the documentation:
victor @vz: ~ $ help exec exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...] Replace the shell with this command.
Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, any redirections take effect in the current shell. Options: -a name pass NAME as the zeroth argument to COMMAND
Regarding the OP comment on this answer: I just tested it on a remote machine using java:
victorz@exa :~$ javac test.java
Perhaps you are not using switch x to ps ? I don't get a match if I don't use the x switch.
Victor zamanian
source share