Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running processes

 
Kasun Liyanage
Greenhorn
Posts: 23
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i need to create an app that iterate through each of currently running processes on the computer. i need to get a handle to each process, handle to each process's window--if it has one--and to read it's caption. i have created this type of thing with C++ but i don't have a clue of doing it with Java. How should i do this, what Java classes libs i should use for doing these system processes specific stuff.
I'll greatly appreciate ANY help.
Thanks!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15492
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is not very well suited for a task like that.

Java is designed to be cross-platform, so things that are very operating-system specific, such as enumerating the processes and finding window handles, cannot be easily done, because Java doesn't provide standard API methods to do very operating-system specific things like that.
 
nishit charania
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

As much I am getting from your request you just need all process name which is ruing on windows system.
That you can get using some windows internal command like "tasklist" or "wmic process list".
This command you can execute using Runtime java api (http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html)
For more information about Runtime api check this link http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

One more solution is you have that c code that gives you all the needed details, modify it as a way that you can get input in java code when you execute that exe using Runtime api.
Or create dll out of your c program and and expose method to java code using JNI.

Good Luck
 
Kasun Liyanage
Greenhorn
Posts: 23
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mates for the replies. Thought java was the god of coding langs Seems like i need to go back to C++ for certain things
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15492
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's always best to use the right tool for the job - and there is not a single tool which is perfect for all jobs. Java is great for many things, but not the best tool for very platform-specific things.
 
Kasun Liyanage
Greenhorn
Posts: 23
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, is it difficult/impossible too to write a program such as a wallpaper changer for windows/linux with java?
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Linux you can usually call a command to do that. For Windows I don't know of any such command, so you'd have to use JNI.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic