i think the title explain the probleme, in fact, if i had a host and a port of running application how we can determine there name with java.
public String getApplicationName(String host,int port) {//some code}
i think the title explain the probleme, in fact, if i had a host and a port of running application how we can determine there name with java.
public String getApplicationName(String host,int port) {//some code}
host and a port of running application
Only operation system is aware of applications that are running now. So it's impossible to get info about processes avoiding writing OS specific
logic.
E.g for Windows
it looks like:
Process proc = Runtime.getRuntime().exec ("tasklist.exe");
InputStream procOutput = proc.getInputStream ();
if (0 == proc.waitFor ()) {
// TODO scan the procOutput for your data
}
Sorry I jumped to conclusion in my comment earlier. I guess getting the process list from the command may be useful. Again OS specific...
try {
String line;
Process p = Runtime.getRuntime().exec("ps -e");
BufferedReader input =
new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line); //
//Run you pattern matcher here to parse data - host & port etc.
}
input.close();
} catch (Exception err) {
err.printStackTrace();
}