• Post Reply Bookmark Topic Watch Topic
  • New Topic

Wake-up Windows XP with Java - JNA / JNI

 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The task of waking a Windows machine from hibernate or standby is pretty easy and well-defined* if you're coding in C++ or .Net, but not so easy (for me) with Java.

Various sources tended to dissuade using JNI because, basically, it was a pain. So I tried JNA:



The above idea, implemented in C++ DOES wake the machine, but seems not to work in JNA. At least I can't get it to wake the machine. As soon as I see "The timer was set..." I suspend the box, but it never wakes up.

I don't even have a C++ compiler and don't really want to invest the effort to get JNI working (hey, at least I'm honest about it), so I've asked for paid help but so far only a few bites. Recently I've expanded the requirement to include JNI, as I think it might be "impossible" under JNA.

The question I have is this: For someone who has a development environment setup for JNI, and (critical) knows how to tread lightly through the JNI environment, wouldn't making a dll for waking the machine from Java be REALLY quick and easy?

--Dale--

* Windows MSDN Documentation:
SetWaitbleTimer http://msdn2.microsoft.com/en-us/library/ms686289(VS.85).aspx
WaitForSingleObject http://msdn2.microsoft.com/en-us/library/ms687032.aspx
Using Waitable Timer Objects http://msdn2.microsoft.com/en-us/library/ms687008(VS.85).aspx

Also, Here's the additions I made to Kernel32.java that allow those JNA calls in the code above work:



[ April 29, 2008: Message edited by: Dale Seng ]

[ April 29, 2008: Message edited by: Dale Seng ]
[ April 29, 2008: Message edited by: Dale Seng ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!