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 the latest java version?
without using arthematic operation ,how can you write the logic for adding/substraction/multiplication?
7 Answers Tanla Solutions, Wipro,
What’s a deadlock?
Is java a utf 8 string?
Why string is not a wrapper class?
Can you explain the cs option of java interpreter?
What are unchecked exceptions in java?
What is file class and what is its purpose?
What are the Abstract Classes provided by Java?
What modifiers are used with an inner class which is a member of an outerclass?
Can variables be used in java without initialization?
What access modifiers can be used for variables?