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.



I want to run a simple hello world java (HelloWorld.java) program using a batch file. How can i ru..

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

Post New Answer

More Core Java Interview Questions

What is an example of procedure?

0 Answers  


Write a program to check for a prime number in java?

0 Answers   Cyient,


If a method is declared as protected, where may the method be accessed in java programming?

0 Answers  


i need income tax program using java inheritance concept. could u please help me?

2 Answers  


How to avoid memory leak in java?

0 Answers  






What are the latest versions in JAVA related areas?

3 Answers   Netcraft,


How many bytes is a string?

0 Answers  


What is the difference between import java.util.date and java .util?

0 Answers  


What is bytecode in java ?

0 Answers  


Describe different states of a thread.

0 Answers  


How many arguments can be passed to main ()?

0 Answers  


What interface is extended by awt event listeners?

0 Answers  


Categories