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

We are seeing so many videos/audios as many web sited. But question is these videos or audios are stored in Databases ( Oracle, Mysql, Sybase,... ) or stored any file directory from there they will give the link for that? Pls explain and give sample code to achieve this one? Thanks, Seenu.

1693


What is udp in java?

733


What is qualitative variable?

719


what is meant by abstract class?

830


What is string made of?

720


Is java 11 paid version?

696


What do u mean by variable?

783


What is ternary operator in java?

804


Is char * a string?

733


Why singleton pattern is better than creating singleton class with static instance?

768


How do you remove spaces in java?

737


Which collection is ordered in java?

721


How do you end a program?

748


How do you do descending order in java?

737


What are the different conditional statements?

742