If I start a screen using screen -dmS screenname java -jar jarfile.jar, will the process java jar jarfile.jar always have a PID that is one value higher than the screen?
As for exec – if I did exec java -jar jarfile.jar, would the process ID of this Java process be one higher than the value of the PID of the shell?
No. PIDs aren’t that predictable. When two processes are started very close to the same time, their PIDs are usually close together, but there’s always the chance that another process started at the same time (another user, a cron job, a daemon that spawned a child in response to some network traffic…) and will get between them.
Also, sequential PID allocation wraps around from a maximum value to a low number. Some systems have 32-bit PIDs but I think 16-bit is more common, so the wrap-arounds are pretty frequent, with a max at 32767 and a minimum of about 700.
Some systems have randomized PIDs as a security feature.