Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

can't access system-level info

  Asked By: Jimmy    Date: Jan 13    Category: Java    Views: 1078

I'm working on a cross-platform instant messaging
app, just like ICQ. I want it to sense whether there
have been any keyboard or mouse actions within the
past 10 minutes so it can automatically set the user's
status to "away." Some folks have told me that a Java
app can't access system-level info like this. Can
anyone give me some pointers?



6 Answers Found

Answer #1    Answered By: Renee Lane     Answered On: Jan 13

Here's a list of the "system" properties Java has
access through via the
java.lang.System.getProperty(String); method.<br><br><br>java.version Java
Environment version <br>java.vendor Java Runtime Environment
vendor <br>java.vendor.url Java vendor URL <br>java.home
Java installation directory
<br>java.vm.specification.version Java Virtual Machine specification version
<br>java.vm.specification.vendor Java Virtual Machine specification vendor
<br>java.vm.specification.name Java Virtual Machine specification name
<br>java.vm.version Java Virtual Machine implementation version
<br>java.vm.vendor Java Virtual Machine implementation vendor
<br>java.vm.name Java Virtual Machine implementation name
<br>java.specification.version Java Runtime Environment specification version
<br>java.specification.vendor Java Runtime Environment specification vendor
<br>java.specification.name Java Runtime Environment specification name
<br>java.class.version Java class format version number
<br>java.class.path Java class path <br>os.name Operating system name
<br>os.arch Operating system architecture <br>os.version
Operating system version <br>file.separator File separator
("/" on UNIX) <br>path.separator Path separator (":"
on UNIX) <br>line.separator Line separator ("\n" on
UNIX) <br>user.name User's account name <br>user.home
User's home directory <br>user.dir User's current
working directory <br><br><br>If you are looking for any
keyboard or mouse  action taking place on the desktop, java
does not have access  to it. <br><br>However, you can
create a "profile" for the person within you ICQ
application which records when the last action taken within
the ICQ app was taken. Then, you can create a timer
thread. <br><br>A keyboard  or mouse action resets the
timer in the thread... If the thread times out, it
resets the status of the profile....<br><br>Something
like this might work.. I haven't done it before, but
that is what I would initally try.

Answer #2    Answered By: Volney Fischer     Answered On: Jan 13

You should be able to do it easily enough. Just
set up a timer that counts seconds since the last
time your app saw a keyboard  or mouse  event, and when
it gets to 600 seconds, you stop the timer and set
the "away" flag. Whenever your app sees a mouse or
keyboard event, reset the counter to 0 seconds, remove the
"away" status and restart the timer if necessary. No
problem ;).

Answer #3    Answered By: Sophie Campbell     Answered On: Jan 13

Would this work even if my app is not in the
foreground? I want my app to have the ability to be in the
background, assume someone is working  in Office or email, and
after 10 minutes  of no keyboard  or mouse  actions in
*any* app, I want my Java app to take an action.

Answer #4    Answered By: Adalwine Fischer     Answered On: Jan 13

The problem is you're
looking for OS-level knowledge of these events which of
course Java doesn't provide, mainly for security
reasons. If you really need to examine all keyboard  and
mouse events system-wide (which in itself is no small
task) Java will be unable to do what you want. C++
might be able to do it, although I don't envy you the
task of figuring out how (keeping in mind that all
keyboard and mouse  events must also be passed to the
proper application as well as "seen" by yours). I don't
believe there's any cross-platform way to do such a

Answer #5    Answered By: Kristin Johnston     Answered On: Jan 13

Can Java know whether the system is asleep or on standby?

Answer #6    Answered By: Beatriz Silva     Answered On: Jan 13

Not without getting the information through native code (for example, a C
application which is accessed through JNI).

Didn't find what you were looking for? Find more on can't access system-level info Or get search suggestion and latest updates.