Skip to content

Instantly share code, notes, and snippets.

@beders beders/jps.js
Created Jun 21, 2015

Embed
What would you like to do?
List of currently running Java processes, color coded using Nashorn
// List running Java Processes
// ansicolors
var a = { reset : "\u001B[0m", black: "\u001B[30m", red: "\u001B[31m", green: "\u001B[32m",
yellow: "\u001B[33m", blue: "\u001B[34m", purple: "\u001B[35m", cyan: "\u001B[36m",
white: "\u001B[37m"
};
var jps = `jps -vl`.split('\n').slice(0,-1);
var ownPID = java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split('@')[0];
jps.forEach(function(j) {
var params = j.split(' ');
if (params[0] != ownPID)
print(a.red + params[0] + a.white + ' ' + (!params[1] || (params[1][0] == '-') ? 'unknown' : params[1]) + a.reset);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.