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 a super class and how super class be called?

3 Answers  


Name and explain the types of ways which are used to pass arguments in any function in java.

0 Answers  


There is a Banking application. It has 2 types of account, Savings and Current. Write a method calculateInterest by passing an ArrayList of these account objects and calculate Interest accordingly. Write code for this situation

1 Answers   ABC, KPIT,


Which java collection does not allow null?

0 Answers  


What is static block?

0 Answers  






public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod

4 Answers   TCS,


What is the scope or life time of instance variables?

0 Answers  


What restrictions are placed on method overriding?

0 Answers  


What is the format specifier?

0 Answers  


Need 2+ yrs experienced java techinical question papaer for company Iflex

1 Answers   TCS,


What are different types of arrays?

0 Answers  


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

0 Answers  


Categories