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 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.









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 Batch Execution
Java Batch Execution  In a statement, I am executing a batch. What is the result of the execution?  It returns the int array.The array... or within a standard transaction. Execution of the batch is not all or nothing
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?  ... Multiple Files Thanks
Java Execution Time Measurement(JETM)
Java Execution Time Measurement(JETM)  How can we integrate JETM in eclipse
different execution time - Java Beginners
different execution time    hello, when i run the bellow code more than one time i am getting different execution time("Total time taken"), Ex... java code therefore due to the execution of other many processes into the system
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
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
execution time calculation - JSP-Servlet
execution time calculation  I want to know how to find out execution time of an algorithm in java thread program.Pls send me an example of a thread program in which i can calculate the execution time of my program.  Hi
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
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
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
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
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
can i estimate estimate execution time for a method without knowing implementation details of a method - Java Interview Questions
can i estimate estimate execution time for a method without knowing implementation details of a method  hi all, can i estimate estimate execution time for a method without knowing implementation details of a method. Thanks
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
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
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
how to sort multiple key columns in CSV file - Java Beginners
how to sort multiple key columns in CSV file  Hi Any one can assist how to sort the multiple key columns in CSV file? Any example will be appreciated. Thanks
Multiple file upload - Struts
Multiple file upload  HI all, I m trying to upload multiple files... Multipale file Uploade Specify file: Specify file: Specify file
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
How can we increase the execution time of a php script?
How can we increase the execution time of a php script?  How can we increase the execution time of a php script
Java Execution
Java Execution  How can you load DLL files when your java class is loading first time
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
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
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
J2ME Read Multiple File - MobileApplications
J2ME Read Multiple File  Hello I have read a topic "J2ME Read File", but that example is specify for a single file, but what if i want read more file one after the other just like Books. And an example will i appreciate thanks
multiple configurstion file in struts - Struts
multiple configurstion file in struts  Hi, Please tell me the solution. I have three configuration file as 'struts-config.xml','struts... in these three config file one by one respectively.So how I can place the code
Multiple file Uploading - JSP-Servlet
Multiple file Uploading   Hello everyone I am using jsp and my IDE is eclipse and back end is ms sql server i am trying to upload multiple... class for JSP: An error occurred at line: 9 in the generated java file
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
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
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
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
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
Source file upload by attaching multiple files
Source file upload by attaching multiple files  Thanks for the answer. The answer posted in this link I want to have a single text box and when i... a provision to attach multiple images/files like in gmail. Is there any solution
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
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
display multiple image file or pdf file in multiple column of a row from server or database
display multiple image file or pdf file in multiple column of a row from server or database  hello sir I have uploaded the file to the server and I want to display that file to the user page but I want to display that file
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML... EMPLOYEES SHOULD BE SAVED IN XML FILE AND MY SQL DATABSE TABLES AT A TIME, AND ALSO
reading multiple files from a directory and writing them into a single file
reading multiple files from a directory and writing them into a single file   i have done the following code but the every time i write to the single file i get an empty text file can you guide me how to do
multiple inheritance - Java Beginners
multiple inheritance  Why java does not support Multiple Inheritance...)why java classes does not support Multiple Inheritance? JAVA CLASSES ONLY NOT SUPPORT MULTIPLE INHERITANCE.But Java Interfaces can support Multiple
Beep in Execution - Java Beginners
file in java but while executing it emitts beep sound everytime it reads from the file and displays the contents of doc file in command prompt. So help me... for my "file reading" problem
Storing Multiple image in sql using java
Storing Multiple image in sql using java  Hi, How to store and retrieve a multiple image in sql using java but already i have created sql table if i want to insert a image while runtime execution. Can anyone tell me solution

Ads