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
What all access modifiers are allowed for top class ?
Why is the singleton pattern considered to be an anti pattern?
What is the difference between yielding and sleeping?
How do you override a method in java?
What is the difference between a method and a function in alice?
What about main() method in java ?
What will happen if a thrown exception is not handled?
Explain reverse a linked list iterative solution in java?
What is anti pattern in java?
What are the approaches that you will follow for making a program very efficient?
What is a modifier?
What type of variable is error flag?
What is scope & storage allocation of global and extern variables? Explain with an example
What is instance example?
What is a locale?