From 54105b5eb3b698c0641c6203497800b01743829d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 16 Dec 2005 21:37:26 +0000 Subject: [PATCH] if -jar, try to get Main-Class from jar manifest --- .../java/src/net/hyperic/sigar/cmd/Ps.java | 72 ++++++++++++++----- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Ps.java b/bindings/java/src/net/hyperic/sigar/cmd/Ps.java index 99bdf972..205da2d8 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Ps.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Ps.java @@ -8,11 +8,16 @@ import net.hyperic.sigar.ProcMem; import net.hyperic.sigar.ProcTime; import net.hyperic.sigar.ProcState; +import java.io.File; +import java.io.IOException; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.jar.Attributes; +import java.util.jar.JarFile; /** * Show process status. @@ -89,6 +94,51 @@ public class Ps extends SigarCommandBase { return true; } + //try to guess classname for java programs + public static String getJavaMainClass(SigarProxy sigar, long pid) + throws SigarException { + + String[] args = sigar.getProcArgs(pid); + for (int i=1; i