Search code examples
javalinuxjnaptrace

Getting info about external processes in linux using JNA- Ptrace?


I'm on a student research team currently working on a Java project in which we want to be able to gather some info about specific external programs in CentOS 7. Some potential examples of data we might want to gather would be the URL from firefox, or the coordinates from Google Earth. Thus far, looking into how to implement this has mostly led me to using JNA and ptrace.

Is this a good route to take to tackle this problem? And if so, what can I use to find the location of specific information about the programs in memory?


Solution

  • JNA and ptrace are quite low level things. To run system applications you should use:

    1. exec method of Runtime class
    2. Apache Common Exec

    Last one is more useful.

    But it seems you don't need to run any application at all. To get information from Google Earth you can just use special web API - Google Maps APIs Web Services. If you want to send HTTP request you should try Apache Http Client. It's very powerful library and i'm pretty sure it's all for you need.

    PS. More convenient client Java Client for Google Maps Services

    PS1. I think java is the worst choice to work with OS and native applications. I see 2 ways to use it:

    1. write agent on C/C++ which will be gather this information for java manager. It's a hard way
    2. use hacks and tricks like here is there a way to get the url from current tab in google-chrome or here Possible to catch URLs in linux?. It's more easy but you will have restricted amount these hacks. And it will work not for all applications and cases.