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
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 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
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
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
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
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 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
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
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
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
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
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
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
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
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
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
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
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
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
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
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 Multiple Insert Query
Java Multiple Insert Query In this example we will discuss about how to execute multiple insert query in Java. This example explains you about how to execute batch insert in Java. This example explains all the steps for executing
Exceptions in Java
- An Exception is Run-time error that arises during the normal execution of Java program... the execution of  java program. The  term exception in java stands ... language during its execution. For example in normal java coding ,you need your
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