I want to run a simple hello world java (HelloWorld.java)
program using a batch file. How can i run it and how to
construct a batch file.
Answer Posted / abdul hannan
Make a source file suppose Hello.java at particular location
C:\javasrc
class Hello {
public static void main(String args[]) {
System.out.println("Hello World");
}
}
open a notepad and write the below command
cd C:\javasrc
javac Hello.java
java Hello > ab.log
Save this file with extension .bat (e.g "run.bat")
double click on run.bat file to run the Hello.java file. You
can see the output in ab.log file on the same path.
if you want to run bat file on command prompt, just remove
the log file(> ab.log) from the batch file and type run. You
can see the output on command prompt.
| Is This Answer Correct ? | 19 Yes | 3 No |
Post New Answer View All Answers
Explain about main thread in java?
What is the purpose of interface?
What is entry set in java?
What is final, finally, finalize?
How do you sort an array in java?
What is difference between call by value and call by reference?
What is a Presistent Object?
Can classes declared using the abstract keyword cab be instantiated?
What is object of class in java?
Why string is called as immutable?
What is floating data type?
Explain java coding standards for constants?
When should the method invokelater() be used?
What is the difference between array and array list in java?
What is the advantage of preparedstatement over statement?