Creating your first Java Application
Creating your first Java Application
To create your first java application, you'll need:- Java SE Development Kit (JDK)
- A text editor
Creating a java file
Write the following code in the text editor:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
System.out.println("Hello World!"); // Display the string.
}
}
}
Save this file as HelloWorld.java
Running the file
If the environment variable is not set, set the environment variable (If you don't know how to set the environment variable, go to this link.)
After setting the environment variable, open command prompt.
To open command prompt, press "Win + R" key and then type cmd and press enter.
To compile your java file, in command prompt type:
javac "Path to your java file or file name"
eg:
javac HelloWorld.java
To run your file, type:
java "Classname"
eg:
java HelloWOrld
Great article, keep up the good work.
ReplyDeleteJava training in Pune