Has the java process been launched from the Perl script or externally? Because you can not wait using waitpid for a process that is not your child.
in reply to Make perl script to wait while external process is finish
If it is an external process, your best option will probably be to use some lock over a file that is also locked by the Java process (or a wrapper) while it runs.
Alternatively, you can check if it is alive looking on the process table (see Proc::ProccessTable for instance) or if it runs as the same user as the Perl script with kill 0, $pid (see kill).