← Back to Core Java Course | Chapter 1: Introduction & Basics | Lesson 3 of 12

Java एनवायरनमेंट सेटअप

Java setup करना अपना workshop तैयार करने जैसा है: आप toolkit install करते हैं, अपनी instructions लिखते हैं, उन्हें computer के follow करने लायक किसी चीज़ में बदलते हैं, और फिर उन्हें चलाते हैं।

What is the JDK?

JDK वह सब कुछ bundle करता है जो आपको Java software बनाने के लिए चाहिए: javac compiler, java launcher, debugging tools, और JRE (जिसमें खुद JVM और core class libraries हैं) सिर्फ compiled programs चलाने के लिए चाहिए।

उदाहरण: What is the JDK?

java
public class Main {
	// The JDK provides: javac (compiler), java (launcher), debugging tools, and the JRE/JVM
	public static void main(String[] args) {
		System.out.println("Built and run using tools bundled in the JDK.");
	}
}

Writing Your Code

कोई भी plain text editor काम करता है, लेकिन IntelliJ IDEA, Eclipse, या Java extension pack वाले VS Code जैसे IDEs यहां असली value जोड़ते हैं -- autocomplete, inline error highlighting, और one-click running जो typos पकड़ना कहीं तेज़ बनाते हैं।

उदाहरण: Writing Your Code

java
public class Main {
	// Written in an IDE like IntelliJ IDEA, Eclipse, or VS Code (Java extension pack)
	public static void main(String[] args) {
		System.out.println("Code written with autocomplete and inline error highlighting.");
	}
}

Saving Your File

Java इसके बारे में strict है: अगर आपकी file public class Calculator declare करती है, इसे बिल्कुल Calculator.java के रूप में save किया जाना चाहिए, case match करते हुए, नहीं तो compiler इसे build करने से मना कर देगा।

उदाहरण: Saving Your File

java
public class Calculator {
	// This file MUST be saved as Calculator.java, matching the class name exactly (case-sensitive)
	public static void main(String[] args) {
		System.out.println("Saved as Calculator.java to match 'public class Calculator'.");
	}
}

Compiling Your Code

अपने terminal से javac filename.java चलाना आपका source पढ़ता है, इसे syntax और type errors के लिए जांचता है, और अगर यह clean है, उसी folder में JVM bytecode रखने वाली एक matching filename.class file emit करता है।

उदाहरण: Compiling Your Code

java
public class Main {
	// Terminal: javac Main.java
	// Checks syntax/types, then emits Main.class (JVM bytecode) in the same folder
	public static void main(String[] args) {
		System.out.println("Compiled with: javac Main.java");
	}
}

Running the Bytecode

java ClassName command (नोट: यहां .java या .class extension नहीं) उस bytecode file को load करता है और इसे JVM को सौंपता है, जो आपके program के main method से execute करना शुरू करता है।

उदाहरण: Running the Bytecode

java
public class Main {
	// Terminal: java Main   (no .java or .class extension)
	public static void main(String[] args) {
		System.out.println("Executed by the JVM starting from main().");
	}
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. सिर्फ JRE setup करना, इसलिए javac नहीं मिलता क्योंकि compiler JDK में है।
  2. JDK bin folder को PATH (या JAVA_HOME) में न जोड़ना, इसलिए java और javac recognize नहीं होते।
  3. Extension के साथ java Hello.class चलाना, जब command java Hello है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.