• Post Reply 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do i run a program every hour from Java (Weekdays only)

 
Greenhorn
Posts: 2
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a program which launches MS Word in Java Eclipse now i want it to launch MS Word every hour including the night (Weekdays only).

Below is my current working code:




It Currently opens MS Word for 20 seconds and closes it .
I want it to open MS Word every hour and after 20 seconds from that hour it should close it and it should do it everyday of the week, every hour day and night.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your try block your'e saying thread to sleep for 20 seconds. After that you kill the process. So yes it kills the process after 20 seconds.

I think you need a process like this :


 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should use an OS-provided facility like cron or Windows Task Scheduler for this, rather than trying to keep a Java process running at all times.
 
Peter Khumalo
Greenhorn
Posts: 2
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to put it together:

So now i should have 2 classes:

and how should they look?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both of you, welcome to the Ranch

I added code tags to your posts, and broke a long line, and doesn't it look better Always use the tags.
Tim is correct; you should not use Java® code at all. What is more, if you are opening Word®, you are using platform‑specific programming, which will probably only work on Windows®, so the Windows®‑specific solution would be correct.
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic