capturing process id

I am newbie to unix shells world.
I am trying to capture a background process id into a file so that it can be killed later.

this process is basically a java program running in background as:
java TestApp &

this returning process id immediately. So how can i redirect that pid into a file. I am Red hat linux.

BTW, whenever you have an initial question, please use the "SEARCH " function before posting. Thanks.

Here is a good post that addresses your problem that I found with search for "capture PID" as the search query.

:):wink: