Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:30:20+00:00 2026-05-22T19:30:20+00:00

i need help to run my Java program on the server at a specific

  • 0

i need help to run my Java program on the server at a specific time like 2 pm (to index the new files).

Someone told me that Java has some thing called jobs but I don’t know how to work with that. I tried this:

 boolean cond=true;
 while(cond){
     @SuppressWarnings("deprecation")
     int heur = new Date().getHours();
     @SuppressWarnings("deprecation")
     int minute= new Date().getMinutes();
     if(heur==16 && minute==02){
         indexer.close();
         end = new Date().getTime();
         File f;
         cond=false;
     }

But with this the program is still running.

How could I run my program at a specified time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:30:21+00:00Added an answer on May 22, 2026 at 7:30 pm

    Theres a API called Quartz, It’s where your program can schedule “Jobs” and it will run it at that time.

    Until I can give an example, try this link.

    Edit:
    First you have to create a class that implements org.quartz.Job. When you implement that you will have to implement the method execute(JobExecutionContext jobExecution), which is the method that will run when the “trigger” is fired.

    To set up the Schedule:

    SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    // Retrieve a scheduler from schedule factory
    Scheduler scheduler = null;
    try {
        scheduler = schedulerFactory.getScheduler();
    }
    catch (SchedulerException e) {
        e.printStackTrace();
    }
    
    //Set up detail about the job 
    JobDetail jobDetail = new JobDetail("jobDetail", "jobDetailGroup", ImplementedJob.class);
    SimpleTrigger simpleTrigger = new SimpleTrigger("Trigger Name","defaultGroup", DATE);
    
    // schedule a job with JobDetail and Trigger
    scheduler.scheduleJob(jobDetail, simpleTrigger);
    // start the scheduler
    scheduler.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to make a cron job to run a java program every 40
I need to create a .bat file to run java program. I have a
Possible Duplicate: Asynchronous shell exec in PHP i need to run a java program
I am starting on java and log4j. I need help with my test program.
I need help optimizing the code to run faster, unless it is optimized the
I need help getting git extensions to run with msysgit. I have had bad
I need help getting a Grease Monkey with JQuery Script to run on a
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
Multi-Test TestNG.xml file results in java.lang.NullPointerException Hello Quality Team, I need help getting TestNG

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.