Java First Program
This is the basic structure of a Java program. Let's understand step-by-step how to write and run it using Eclipse , VS Code , or JDK + Text Editor like EditPlus.
यह एक साधारण Java प्रोग्राम है। चलिए इसे Eclipse, VS Code, या JDK + Text Editor जैसे EditPlus में step-by-step लिखना और चलाना सीखते हैं।
Download Resources / डाउनलोड करें
Step-by-Step: Run in Eclipse or VS Code
Open your IDE (Eclipse or VS Code).
Create a new Java project (e.g., "MyFirstProject").
Create a new Java class file named HelloWorld.java
.
Copy the following code into the class file.
Save the file and click Run or press F5 / Ctrl+F11 .
You will see the output window showing: Hello, World!
अपने IDE (Eclipse या VS Code) को खोलें।
नया Java प्रोजेक्ट बनाएं (जैसे "MyFirstProject")।
HelloWorld.java
नाम से नया Java क्लास फाइल बनाएं।
निम्नलिखित कोड को क्लास फाइल में कॉपी करें।
फाइल को सेव करें और Run पर क्लिक करें या F5 / Ctrl+F11 दबाएं।
आपको output विंडो में Hello, World!
दिखेगा।
Step-by-Step: Run Using JDK + Text Editor (EditPlus)
Install the latest JDK and set up the PATH environment variable.
Open EditPlus (or any text editor).
Create a new file and write your Java program below.
Save the file as HelloWorld.java
(class name must match).
Open Command Prompt (Windows) or Terminal (Mac/Linux), and navigate to the file location.
Compile the Java file with the command: javac HelloWorld.java
Run the compiled program with the command: java HelloWorld
You will see the output: Hello, World!
सबसे पहले JDK डाउनलोड और इंस्टॉल करें और PATH सेटअप करें।
EditPlus (या कोई भी text editor) खोलें।
नई फाइल बनाएं और नीचे दिया गया Java कोड लिखें।
फाइल को HelloWorld.java
नाम से सेव करें (class का नाम वही होना चाहिए)।
Command Prompt (Windows) या Terminal (Mac/Linux) खोलें और फाइल के फोल्डर में जाएं।
Java फाइल को कंपाइल करें: javac HelloWorld.java
प्रोग्राम चलाएं: java HelloWorld
आउटपुट में Hello, World!
दिखाई देगा।
Java Program Code
Copy
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Output:
Hello, World!
Explanation (English):
public class HelloWorld
: Defines a class named HelloWorld.
main()
: The entry point method where execution starts.
System.out.println()
: Prints text to the console.
The program prints Hello, World!
and ends.
व्याख्या (Hindi):
public class HelloWorld
: HelloWorld नाम की एक class बनाता है।
main()
: मुख्य method है जहाँ प्रोग्राम शुरू होता है।
System.out.println()
: स्क्रीन पर text print करता है।
प्रोग्राम Hello, World!
print करके खत्म होता है।