Is it possible to enable port in JSVC for remote d

2020-07-18 09:01发布

问题:

I am running a jsvc application which is working absolutely fine but now I need to enable one port on my application so that I can do remote debugging. I am performing above task using java.

Is there any way to achieve above task ? I have checked all JSVC option http://commons.apache.org/proper/commons-daemon/jsvc.html but didn't find anything.

Here is the code of adding jsvc parameter :

private List getJSVCArgs(){ List jsvcArgs = new ArrayList(); jsvcArgs.add(jsvcDir+"/jsvc"); jsvcArgs.add("-pidfile"); jsvcArgs.add("pidfile.pid"); jsvcArgs.add("-outfile"); jsvcArgs.add("outfile.txt"); jsvcArgs.add("-errfile"); jsvcArgs.add("errfile.txt"); jsvcArgs.add("-wait"); jsvcArgs.add(String.valueOf(jvmProperties.get("-wait"))); jsvcArgs.add("-user"); jsvcArgs.add(System.getProperty("user.name")); jsvcArgs.add("-home"); jsvcArgs.add(System.getProperty("java.home")); return jsvcArgs; }

Now I need to pass this "-agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n" to JSVC. Anyone has any idea how to achieve it ?

回答1:

As Waheed discover himself, you can add add the needed parameters to jsvc like this:

jsvcArgs.add("-agentlib:jdwp=transport=dt_socket,address=8001‌​,server=y,suspend=n")‌​;