Is Windows process Running, Java differentWindows OS on Different Lanaguages
I 开发者_JAVA技巧am using Java in programing and want to watch after some processes if running or not. I have to make my implementation platform indepenant; support different OS (Windows XP,7 & 2000) also this OS in different lanaguages (French, English, Japaness, Chiness, Arabic , RTL etc ...)
I tried first to use command line, but I was faced with a problem that the command reply is in the OS language so it replies in French if OS is french and in English if English.
I used the command in different way, but was faced with another problem which is encoding, so I have to set the encoding to UTS8 before calling the command, this worked will with English & French but I doubt it will work with Chiness & RTL languages.
Do you have any clue for a better Solution ?
Thanks in advance
There is no universally accepted way for doing this because all operating systems are very different. The two approaches we have available are probably the best. If you run into language problems with tasklist perhaps you should then take a look at the vbs version. The upside in that is that it should work independently of the language and Windows version.
I am using Java in programing and want to watch after some processes if running or not.
Frankly, this is a problem that is difficult to solve in Java. Java is meant to be cross-platform, hence it isolates you from platform-specific features. Therefore there is no "official" way to get a list of running processes in Java. There are some hacks (such as invoking "tasklist", as explained by erloewe), but no real solution.
Your best bet is probably to write a program in some other language (e.g. C, Perl or VBScript), and invoke it from Java.
精彩评论