Time schedular for multiple batch file execution in java

Ads
 

Time schedular for multiple batch file execution in java

Hello All,

i have a task in which i have to design a time schedular in java in which i can automate the batch file execution for the wholw day.

For example i should have a GUI in which i can see the like calander and assign the time slot 07:00 to 9:00 for batch1.bat execution. 09:30 to 10:30 for batch2.bat execution. therfore when i open it again also than i can see which time slot is free to assign another execution.

Please help me on this.

View Answers

May 27, 2013 at 11:19 AM

hi friend,

Try the following code, may this will be helpful for you. Code that is being given below will help you understand how to execute a batch file as a schedule.

package net.roseindia.schedular;
import java.io.IOException;
import java.util.TimerTask;
import java.util.Date;
import java.util.Timer;
import java.util.concurrent.TimeUnit;

class Task extends TimerTask {

    public void run() {
        try {
            Runtime.getRuntime().exec("cmd.exe /c start C:\\BatchFile\\run.bat");
        } catch (IOException e) {           
            e.printStackTrace();
        }
    }
}

public class JavaSchedular {
    public static void main(String args[]) throws InterruptedException {

        Timer timer = new Timer();
        Date date = new Date();
        Task task = new Task();
        timer.schedule(task, date ,TimeUnit.SECONDS.toMillis(2));
    }
}

Thanks.


May 27, 2013 at 9:09 PM

Thanks alot for the reply. Is it possible that user should have a dialog box in which he will enter the batch file paths and enter the date and time for execution.

After this he should press a button EXECUTE and after that the batch file should run in the entered Time.

Please help me on this as i do not have much exoerinec with GUI therefore struggling with this task... :(

I am waiting for your solution.

Ads









Related Tutorials/Questions & Answers:
Time schedular for multiple batch file execution in java
Time schedular for multiple batch file execution in java  Hello All, i have a task in which i have to design a time schedular in java in which i can automate the batch file execution for the wholw day. For example i should have
Execution of Multiple Threads in Java
Execution of Multiple Threads in Java  Can anyone tell me how multiple threads get executed in java??I mean to say that after having called the start method,the run is also invoked, right??Now in my main method if I want
Advertisements
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  How can we integrate JETM in eclipse
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  Whether JETM can be implemented in Struts framework especially in Struts2. If not,tell the alternative solution
multiple file upload at a time like gmail
multiple file upload at a time like gmail  I want to upload multiple files at a time like gmail. is there any possiblity/solution to do that?   Hi Friend, Please visit the following link: Upload Multiple Files Thanks
Batch file for java application
Batch file for java application  please tell me how to create the batch file for java application(using swings).the application is created with netbeans
Java example to calculate the execution time
Java example to calculate the execution time       get execution time This example program will describe you the way that how one can calculate or get the execution time
to know execution time
to know execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... to know the execution time for where,having and group by separately.If
ModuleNotFoundError: No module named 'Execution-Time'
ModuleNotFoundError: No module named 'Execution-Time'  Hi, My... named 'Execution-Time' How to remove the ModuleNotFoundError: No module named 'Execution-Time' error? Thanks   Hi, In your python
How to Increase Script Execution Time Limit in php ?
avoid this error by increasing script execution time limit in your PHP.INI file...How to Increase Script Execution Time Limit in php ?   Increase Script Execution Time Limit in php configuration   Sometimes you need
to know sql qyery execution time
to know sql qyery execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... possibility to know the execution time for where,having and group by separately.If
to know sql qyery execution time
to know sql qyery execution time  Hai this is sravanthi Is there any possibility to know the execution time of an SQL in its order to execute... possibility to know the execution time for where,having and group by separately.If
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
maximum execution time of 30 seconds exceeded in php
maximum execution time of 30 seconds exceeded in php  My PHP program is taking long time to run it is giving following error: Maximum execution time of 30 seconds exceeded in php file How to resolve this issue? Thanks
Sort last modified file time in java
Sort last modified file time in java  How to sort the last modified file time in java?   import java.io.*; import java.util.*; import...[] args) throws IOException { File file = new File("C:/file.txt
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
Multiple File Upload in PHP
Multiple File Upload in PHP  Hi, I am beginner in PHP scripting language. I am very interested to learn PHP application. So, can anyone explain or provide related reference about how to Multiple file upload in PHP. Thanks
how to execute a file in java at regular time intrevals automattically
how to execute a file in java at regular time intrevals automattically  how to execute a file in java at time retrievals automatically
Take input in batch file
Take input in batch file  How to take input in batch file? Thanks   Hi, You can use the following line of code in your batch file: set /p myfile=Enter file name: In the above code myfile variable will hold the data
inserting multiple file formats into database
inserting multiple file formats into database  hi i want to insert multiple file format like .pdf.doc.zip into mysql database using jsp
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
Source file upload by attaching multiple files
Source file upload by attaching multiple files  Hi, I am trying to develop a file upload with multiple files attached functionality in java(like... un-check the file it should be removed. Due to time constraints I can not do
Using the escape percent in the batch file
Using the escape percent in the batch file   If you use the one % in the batch file it will consider it as the parameter input and will try to find the variable and replace it. But how to use the percentage in batch file
ModuleNotFoundError: No module named 'schedular'
ModuleNotFoundError: No module named 'schedular'  Hi, My Python... 'schedular' How to remove the ModuleNotFoundError: No module named 'schedular' error? Thanks   Hi, In your python environment you
execution of java program
execution of java program  wat are the steps for the execution of the servlet-jdbc program on tomcat 5.5 server.. PlS provide..the execution steps in detail..including the setting of classpath in DOS for mysql-connector-java. i
Getting the modification date and time of file or folder in Java
C:\nisha>java GetDirectoryAndFileModifiedTime Enter file or directory name in proper format to get the modification date and time : myfile.txt File name : myfile.txt File modification date
importing excel file and drawing multiple graphs from one excel file
importing excel file and drawing multiple graphs from one excel file  thanks a lot sir for replying with code for importing excel file... time from one excel file using different columns..and instead of passing column
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
quartz schedular in spring mvc
quartz schedular in spring mvc  how to apply auto emailing through sping mvc and want to pass some variable to that trigger job
create csv file in php in multiple columns
create csv file in php in multiple columns  i need create csv file in multiple columns like this: id name age date_added 1 john 23 2012-2-12 2 jane 25 2012-3-14 i can build csv file like this: id,name,age,date
create csv file in php in multiple columns
create csv file in php in multiple columns  i need create csv file in multiple columns like this: id name age date_added 1 john 23 2012-2-12 2 jane 25 2012-3-14 i can build csv file like this: id,name,age,date

Ads