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 difference between variable declaration and definition?
Why do we create threads in java?
what is the messsage u r going to get from an objectoriented programing?
How do you access command-line arguments within the code?
0 Answers Flextronics, Hexaware,
What are filterstreams?
How many types of java are there?
Why to use nested classes in java? (Or) what is the purpose of nested class in java?
Explain inner classes ?
What is the difference between static and non-static variables in java programming?
What is inner class?what is the use of inner class?where we create the object for inner class? and inner class can extend any class or inner class can implement any interface?
How to overcome the exception object reference not set to an instance of object?
Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.