Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: Getting list of Apps in java

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Getting list of Apps in java

    Hi,

    I want a list of all running application in my java code.I got list of all the running processes by my code but I dont want that. I want only main Application. Like if two application are running in my pc then I should get only those application's Name.Please help me, its urgent.Any help will be appriciated.

    Thanks in advance.


  2. #2
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting list of Apps in java

    Are you talking about a task the operating system would do for you?
    Task manager handles executable applications at the time of viewing it.

    I'm a little confused as to what you mean. You can run code profiler through
    the IDE but I doubt that's what you want either.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  3. #3
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Getting list of Apps in java

    Are you trying to get a list of processes running on the machine? It's not a very Java'ery thing to do because the solution depends on the platform (windows, mac, linux, etc). There is no platform independent way of doing this. On Linux I would make a system call to ps -e

    Process p = Runtime.getRuntime().exec("ps -e");

    whereas on Windows I would execute tasklist.exe
    Computers are fascinating machines, but they're mostly a reflection of the people using them.
    -- Jeff Atwood

  4. #4
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting list of Apps in java

    Thx Ada for your rply. I want the list of Application that are currently running in my pc in Which windows 8 is installed.I need this list through Java code.So, Please rply with sample code.

    --- Update ---

    Thanks for your reply ChristopherLowe. But using the code you have given I am getting all the process list. But I want only main application list like if notepad and windows media player is running in my pc then I should get the list having these two application name.

  5. #5
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting list of Apps in java

    So basically you want to write a Java application that displays to you
    that the main method is running?

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  6. #6
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting list of Apps in java

    No. suppose in my pc notepad and windows media player is running then I should get the list by the java code that gives me this two application name.

  7. #7
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting list of Apps in java

    Right - so you want to write a Java application that when executed, will
    display something like:

    Execution begins...
     
    Application Name: Windows Media Player v.12 - Running
    Application Name: Microsoft Notepad Text Writer - Running

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  8. #8
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting list of Apps in java

    Yes Ada Exactly like this I want..

  9. #9
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Getting list of Apps in java

    You are going to have a hard time with that. The operating systems task manager only care about processes. A process can have zero, one or many windowed applications associated with it and in odd cases like chrome, many processes associated with the one window. An exact solution would require poking around in the low level windows bindings for each process, a task that C# for windows or C for linux would be better suited for.

    A way to cheat the results you are after would be to create a whitelist of processes such as chrome.exe, notepad.exe, etc and compare it against the result of ps -el or taskmanager.exe. It's an order of magnitude more simple but requirements the you have a list of all the applications you are interested in.
    Computers are fascinating machines, but they're mostly a reflection of the people using them.
    -- Jeff Atwood

  10. The Following User Says Thank You to ChristopherLowe For This Useful Post:

    Ada Lovelace (August 19th, 2014)

  11. #10
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting list of Apps in java

    So, is it not possible to get the list like my requirements?

  12. #11
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Getting list of Apps in java

    Not with the standard library. Maybe there is some 3rd party library out there which does it with native code.

  13. #12
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting list of Apps in java

    Quote Originally Posted by Alex Stup View Post
    So, is it not possible to get the list like my requirements?
    Like Christopher said previous, it is possible, but it's going to require a lot of low level
    digging and you may even have to re-consider if Java if the best language for this type of application.
    Low level system work is not what Java was designed for, being a high level language.

    Another thing you may have to look out for is permissions created by software vendors. Some
    OS specific tasks might have access blocks to prevent hacking.

    Can I also ask, what is the purpose of this request in general

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

  14. #13
    Junior Member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting list of Apps in java

    I am developing a system that keeps the record of user's usage in pc.So, i need to know which application is running in his pc.So, I need this kind of list in my code. I am getting the list of processes but not the list of apps.

  15. #14
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Getting list of Apps in java

    C# has more or less this capability, this might be what you want:

    Display Running application list of desktop using c# - Stack Overflow

    If you want the Java version, I would follow Cornix's advice.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

Similar Threads

  1. Replies: 3
    Last Post: October 5th, 2013, 09:14 AM
  2. WAMP : Advisable database to use for java apps or not?
    By ZDreamer08 in forum Java Theory & Questions
    Replies: 0
    Last Post: October 1st, 2013, 04:55 AM
  3. iPhone apps with java
    By vahik92 in forum Java ME (Mobile Edition)
    Replies: 5
    Last Post: January 3rd, 2011, 05:51 AM
  4. help with java apps.
    By Brt93yoda in forum Java Theory & Questions
    Replies: 5
    Last Post: August 30th, 2010, 11:36 AM
  5. Bluetooth for commercial java apps
    By alex100 in forum Java Networking
    Replies: 0
    Last Post: March 6th, 2010, 06:28 PM