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 / 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 |
What is meant by class loader and how many types are there?
Which collections are thread safe in java?
what is jms? features of jms
Can we sort hashmap in java?
What is a jagged array in java?
What are the different tags provided in jstl?
how can we import the user defined package without classpath?
What is data and its types?
What is the collection interface?
how many types of cloning?
Java violates few objected oriented concepts. Can you explain in what way?
What is the life-cycle of an object?