title: Capture Java program name/package name from process command line using Regex
body: <p>I need to extract Java program name/package name from its process command line. An example of process command-line is </p>
  
  <p>/usr/lib/jvm/jdk1.8/bin/java -Dzookeeper.datadir.autocreate=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE -cp /usr/lib/zookeeper/bin/../build/classes:/usr/lib/zookeeper/bin/../build/lib/<em>.jar:/usr/lib/zookeeper/bin/../lib/slf4j-log4j12.jar:/usr/lib/zookeeper/bin/../lib/slf4j-log4j12-1.7.5.jar:/usr/lib/zookeeper/bin/../lib/slf4j-api-1.7.5.jar:/usr/lib/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/usr/lib/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/lib/zookeeper/bin/../lib/jline-2.11.jar:/usr/lib/zookeeper/bin/../zookeeper-3.4.8.jar:/usr/lib/zookeeper/bin/../zookeeper-3.4.5-cdh5.15.0.jar:/usr/lib/zookeeper/bin/../src/java/lib/</em>.jar:/etc/zookeeper/conf::/etc/zookeeper/conf:/usr/lib/zookeeper/<em>:/usr/lib/zookeeper/lib/</em> -Dzookeeper.log.threshold=INFO -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf-d/zoo.cfg</p>
  
  <p>I need to capture org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf-d/zoo.cfg</p>
  
  <p>I am using a regex (?:(?:.<em>bin/|^)java\s.</em>?-cp)(?:\s.<em>jar.</em>?)+(\s(?:(?!-).)+) which captures org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf. </p>
  
  <p>Need help in fixing the regex or a better way of capturing the program name.</p>