Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Running Batch files in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Akhilesh
Running Batch files in java
1 Answer(s)      5 years and 10 months ago
Posted in : Java Beginners



Advertisement
View Answers

March 13, 2009 at 7:08 AM


Hi Friend,

Here we are sending you some sample program code for running batch (.bat) file in Java. We have used "exec()" command for running the batch file. Suppose we have created a batch file "notepd.bat" which calls the notepad and this is responsible for opening a notepad.

notepd.bat
==========

echo "This would open notepad"
CALL notepad

Our java class is "CallBatchFile.java" who runs the bat file.
CallBatchFile.java
==================
import java.io.*;
class CallBatchFile{
public static void main(String args[]){
try
{
System.out.println("Start Running the batch file");
Runtime.getRuntime().exec("notepd.bat");
System.out.println("Completed");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

Output :
C:\>javac CallBatchFile.java

C:\>java CallBatchFile
Start Running the batch file
Completed
and one notepad window will be open.

Thanks & Regards
RoseIndia Team


Related Tutorials/Questions & Answers:
Running Batch files in java - Java Beginners
Running Batch files in java  Hi, I am writing a program which... are sending you some sample program code for running batch (.bat) file in Java. We have... and every line from the batch file and execute it line by line in java. Is anyone
Running a stand alone application using batch file in windows
Running a stand alone application using batch file in windows  I have... application. All the .class files are available inside a package called as com.tbss. I have included all the jar files inside the present working directory.I have used
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 Batch Execution
Java Batch Execution  In a statement, I am executing a batch. What... contains the affected row count in the corresponding index of the SQL. batch... count and error information. The batch may be executed during autocommit
i want to copy files from one machine to other using java and the code will be running on third machine
i want to copy files from one machine to other using java and the code will be running on third machine  i want to copy some files from one machine say 'A' to some other machine say 'B' by using the java program running on third
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
executing a batch file which depends on jar files from a system tray but console should not display.
executing a batch file which depends on jar files from a system tray but console should not display.  Hi all, I got following requirement, I have to run a batch file which is depending on some jar files and it displays a frame
Running Java Applications as software
Running Java Applications as software   Please tell me what to do if you want your java application to run like a real software,eg a java GUI application that connects to the database(Mysql)running on the computer like any other
running java with classpath in cygwin
running java with classpath in cygwin  The following command works in cmd.exe but failts in cygwin shell. java -cp .;oracle.jar;mysql.jar Executecmd query value; how should i alter the command to run in the bash shell?thanks
PreparedStatement using batch update - Java Beginners
PreparedStatement using batch update  How to execute different preparedStatement object using batch update(Java) Pls explain with the code. Thanks  Hi Friend, Try the following code: import java.sql.
Running core java program
Running core java program  I am jayesh raval. I am going to make simplae program and at the time of runnint that program I found class not found exception. I have clear source of that program and that is right in the syntax. so
JDBC batch insert using Java bean class
In this tutorial, you will learn about JDBC batch insert using java bean / model class
Java Not running - Java Beginners
Java Not running  Hi, I tried to create a grade(type array) and final_grade (type of String) program using getter/setter but not want a public setter method for final_grade; Here is my program that calcuate the average of all
process of compiling and running java program
process of compiling and running java program  Explain the process of compiling and running java program. Also Explain type casting
Running Java Applications as a Windows Service
Running Java Applications as a Windows Service  sample code for "Run a Java application as a Windows Service
batch in jdbc
JDBC BATCH PROCESSING    In Batch processing, many queries work together as batch. The following program include collective set of SQL queries executed altogether to the database.".addBatch()" method is used to add
Building and Running Java 8 Support
Building and Running Java 8 Support  As you know Java 8 is already released and available for download. Now I am developer of Java based projects. So... and run Java 8 application in Eclipse? Thanks   Hi, don't worry
Server running Button - Java Beginners
Server running Button  Hi there, I have a created a GUI using NetBeans IDE 6.1. The aim of this interface is to display the messages that have been recived by the server , when the client is connected , in the textArea
Java Compilation and running error - RMI
Java Compilation and running error   The following set of programs runs with the lower versions of Java 6 update 13, but not with JAVA 6 update 13... some problem and gives following on compilation"java uses unchecked or unsafe
java files - Java Beginners
java files  Hi! How to create files (not temporary) when i got exception in my java program. I want to write the complete exception in file...://www.roseindia.net/java/example/java/io/ Thanks
Trouble in running Dos Command from Java Servlet
Trouble in running Dos Command from Java Servlet  Hello All, I have to run following command from Java. The command is : vscanwin32 /S C:\Test > C:Scan_Result.txt vscanwin32 is resided at location: C:\Program Files\Trend
regarding java files genarated by jsp
regarding java files genarated by jsp  Hi,... I'm running a project...: 233 in the generated java file Syntax error, insert "}" to complete Block" Where to find the genarated java file??? Thank u in advance
Reading files in Java
suggest for Reading files in Java? Thanks...Reading files in Java  I have to make a program in my project... file in Java. What is the best way to read the file in Java as its big file
Java files - Java Beginners
Java files  i want to get an example on how to develop a Java OO application which reads, analyses, sorts, and displays student project marks.... The input files are structured as follows: ˆ one student record per line ˆ
Copy Files - Java Beginners
Copy Files  I saw the post on copying multiple files (http://www.roseindia.net/java/example/java/io/CopyMultipleFiles.shtml) and I have something... a list of JPEG files that my boss gave me, and I was planning on putting them
java and files - Java Beginners
java and files  hi this is varun working for a software company. i have one doubt that is i have written a program for accessing the xml file from java code,its get executed for that i have used XML Prser. but now
java web application without running tomcat
java web application without running tomcat  I did a project by using jsp,html,javascript,css,tomcat,editplus and MSAccess as backend..i created set... is there any way to run the web application(only in single system)without running
files - Java Beginners
files  Why do we require files to store data?  Hi friend, files to store data, easy to find and access them. Thanks
configuration files - Java Beginners
configuration files  i have to use configuration file in my program "listing of number of files and their modified time of directory",but problem is that directory name should be provided through configuratin file not input
listing files - Java Beginners
listing files  how to list the files and number of files only...]); System.exit(0); default : System.out.println("Multiple files...]); System.exit(0); default : System.out.println("Multiple files are not allow
error while running the applet - Java Beginners
error while running the applet  import java.applet.Applet; import...); ++num; } } } } i have problem while running the code , error... is correct but u have problem in running the program. You follow the following steps
Advertisements
 

 

 

DMCA.com