While launching AWS EC2 instance the java program is not executing what might be the issue?

I have two Java programs in my EC2 instance which is launched in a public subnet. The programs are stored under /home/ec2-user/559 folder as jar files named response_server.jar and server.jar. server.jar file is listening on port 5000 to talk to a client and response_server.jar is listening on port 6000 . ELB is configured to ping the EC2 instances on port 6000 for health checking and hence response_server.jar is used to return a random response when pinged on port 6000 (mainly for ELB)

I am having two issues :

First issue : When I ssh in to the EC2 instance and manually run the jar files using the command below, they work as expected and my client program receives the response on both port 5000 and 6000 .

Now, if I connect the client program, I get an error that the connection is refused. Unless I manually run them in the ssh session, it doesn't connect.

Second issue : Kind of related to the first issue, my ELB shows this EC2 instance as unhealthy unless I manually run the jar files for ELB to check the health status on port 6000.

I am unable to figure out why the java programs arent launching when rebooting the EC2 instance when using the launch script. I checked to see if the ports are open after booting the instance and find that the ports are not in listening state.