*
The moose likes Java in General and the fly likes Firing a Java Code on a scheduled time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Firing a Java Code on a scheduled time" Watch "Firing a Java Code on a scheduled time" New topic
Author

Firing a Java Code on a scheduled time

Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
hi, iam new to java but i worked in lotus domino technology as a developer. In that technology, we used to create agents which can be fired :-
1) on Event,
@) or on scheduled time

here in java, iam wondering how a piece of code in java is fired on both these events(event/scheduled)

i think that depends on server which we use.
Is that depends on IDE also.
iam using Eclipse with Tomcat application server.

I would really appreciate your help in providng me the basic working of it.
thanks in advance....


Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270
    
    8

Which "Event" is that? Some user action like clicking a button? Some database trigger? Something else?

If the IDE is going to dictate your code, then you have picked up a bad IDE indeed.
Since you mentioned Eclipse, I do not think Eclipse puts down any such limitations.

Check out Quartz. It is an open source scheduling framework which lets you practically do all kinds of scheduling jobs.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Vinod Vinu
Ranch Hand

Joined: Aug 30, 2009
Posts: 217
on Event like clicking on a button
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270
    
    8

What you will need is listeners

If you are using a JButton you will need something like



If you are taking some action when a particular button is clicked, you don't need a scheduler, unless you want the action to be taken in the future.
Also check out the javax.swing.Timer class.
These two links might also be helpful
http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html
http://java.sun.com/products/jfc/tsc/articles/timer/
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

iam using Eclipse with Tomcat application server.

Are you making a web application ? The button you click are on web pages ?


[My Blog]
All roads lead to JavaRanch
 
wood burning stoves
 
subject: Firing a Java Code on a scheduled time