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


Please Help Members By Posting Answers For Below Questions

What is stack class in java?

536


Can we modify the throws clause of the superclass method while overriding it in the subclass?

543


What is a qms manual?

535


Explain about public and private access specifiers?

528


Does java initialize arrays to zero?

497






How can we create objects if we make the constructor private ?

535


what is abstract class in Java?

645


What is identifier give example?

545


Does constructor creates the object ?

576


Difference between comparator and comparable in java?

606


Does google use java?

522


If an application has multiple classes in it, is it okay to have a main method in more than one class?

532


What is the meaning of variables in research?

522


What is a 16 bit word?

559


What is difference between float and double?

494