Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Suggestions required for solving a Java problem

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Respected Members,
I am working on a project from quite some time, during this time I have consulted different books, web sites, posted various messages on various forums but still unable to get the solution, actually the solution which I am aiming should be purely Java based, below I am first stating the scenario and than my questions, I would be waiting for replies from your side, please give me suggestions that how to make this thing possible and please help me finding some pure Java solution to this problem(if a pure java solution) exists), following is the scenario:

Scenario:

I want to make a Java application which is continuously running in memory, by �continuously running in memory� I mean that when ever I start my PC the application starts running at the back end just like a Windows Service without any user intervention and when the PC is closed the application will off course stops working like all other windows services. Now what this application has to do is to continuously monitoring all the key strokes pressed from the keyboard by the user, when ever a user presses Ctrl-F3 ( pressing Control key and F3 keys together) than a pop up message will appear on the screen but if the user presses some other key or a combination of different key strokes than nothing will happen. This is the complete scenario which I am facing, now the questions which I have are as follows:

Questions:

1) How can I trap an event ( any particular key press event) from a Java program which is running in the windows service, handling key board events for a GUI based forms is quite simple but how can I trap an event for such a program, how can I bind my key press events to this program.
2) My second question is that how to add a Java program to a windows service so that every time I start my PC my program like all other services also starts running.
3) Last but not the least that I need a pure Java based solution, is this really possible and if not than what are the other ways to solve this scenario.

Thanking You in advance.
[ July 25, 2007: Message edited by: Bilal Ali ]
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You can run a Java program as a Windows service. But not with Pure Java. You need either to find one of the third-party libraries that do it (Google for them) or write your own in Java Native Interface, JNI (like we did here).

I don't think a Java program can intercept all keypresses, without further native code.

So, in summary, your requirements probably can be met, but not with Pure Java.
 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What I have understood from your reply that I need to write some function in some other language which would monitor the key press events,is that what you are trying to say and if yes than what these languages may be, can it be done in VB and as you said that we can not monitor all the key events than what key events can be handled.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Bilal --

You've asked exactly this question, over and over again, using different words each time, in half a dozen forums here, for the last two weeks. You've got all your answers. I'm going to summarize them here:

1) You can't do this all in Java; and in fact, there's no point in doing any of it in Java, since all the functional parts would be in the native code. There's no point in gluing any of it into a Java program since the Java parts wouldn't do anything.

2) It's a Windows-specific program, so you should just do it in a .NET language, or in C/C++ with Win32.

3) If you don't know how to do (2), then you either need to learn how, or hire somebody else to do it.

4) Since it's inappropriate to ask how to do (2) in a Java forum, you need to take all this elsewhere -- to a Windows programming forum, I suppose.
 
    Bookmark Topic Watch Topic
  • New Topic