Get PID javaws jnlp applet under linux

I am trying to run the java (jnlp) applet from bash and get the PID of the created process.

With this command:

javaws myapplet.jnlp > /dev/null & echo $! 

Returns the pid of the first java instance that jnlp loads; I think, but has nothing to do with the java terminating process.

Any clues?

Found the original javaws as follows:

 #!/bin/sh prog="$0" while [ -h "$prog" ]; do prog=$(readlink -f $prog); done [ $# -eq 0 ] && set -- -viewer exec $(dirname $prog)/javaws.real "$@" 

Is there a way to change it to give the PID of the child process?

+3
java linux jnlp
Aug 16 '10 at 11:56
source share
2 answers

Create an agent.jar file and load it using the -J javaws . The -J arguments are passed directly to the target virtual machine and combined with vm args in the .jnlp file, so you can load the local agent library in the same process as the application.




Example:

This agent library contains the premain method, which stores the current PID (access via JNA ) in a text file.

Assuming getpid.jar and jna.jar are in the current directory, it can be started with:

 javaws -J-javaagent:getpid.jar=pid.txt myapplet.jnlp 

This will launch the applet after writing its PID to the pid.txt file.

+3
Aug 25 '10 at
source share

I don't know if this will do the trick, but find the pid, in general, I use this alias

 alias prs='ps faux|grep -v grep|grep "$@"' 

and then

 prs my_prog 
+1
Aug 16 2018-10-12T00:
source share



All Articles