← Back to Kotlin Course | Chapter 1: Setup & Basics | Lesson 3 of 7

IntelliJ IDEA सेटअप करना

IntelliJ IDEA Kotlin के लिए बना एक smart text editor है जो आपको type करते समय गलतियां बताकर सही code लिखने में मदद करता है।

Why IntelliJ IDEA?

IntelliJ IDEA, JetBrains का अपना IDE है, और चूंकि JetBrains ने Kotlin भी बनाई, IntelliJ सबसे पूरा Kotlin support देता है: instant error checking, auto-completion, refactoring tools, और एक integrated debugger।

Note: मुफ़्त Community Edition इस course जैसे plain Kotlin/JVM projects को पूरी तरह support करता है।

उदाहरण: Why IntelliJ IDEA?

markup
// Entry point: execution of the program starts here
fun main() {
    // Print "IntelliJ IDEA gives instant feedback while you type Kotlin" to the console, with a trailing newline
    println("IntelliJ IDEA gives instant feedback while you type Kotlin")
}

Creating a New Kotlin Project

Welcome screen से, New Project -> Kotlin चुनना आपको एक build system (Gradle या IntelliJ) और एक JDK चुनने देता है। एक minimal Kotlin/JVM console project को code चलाना शुरू करने के लिए बस इतना ही चाहिए।

उदाहरण: Creating a New Kotlin Project

markup
// Entry point: execution of the program starts here
fun main() {
    // Print "A new Kotlin project created in IntelliJ IDEA" to the console, with a trailing newline
    println("A new Kotlin project created in IntelliJ IDEA")
}

Running Code with the Green Arrow

IntelliJ किसी भी fun main() function के बगल में एक छोटा green triangle दिखाता है; उस पर click करना उस file को तुरंत compile और run करता है, window के नीचे Run panel में output दिखाते हुए।

Note: Shift+F10 (या macOS पर Ctrl+R) बिना mouse छुए आखिरी चलाई configuration को फिर से चलाता है।

उदाहरण: Running Code with the Green Arrow

markup
// Entry point: execution of the program starts here
fun main() {
    // Print "Click the green run arrow next to main() to execute this" to the console, with a trailing newline
    println("Click the green run arrow next to main() to execute this")
}

Using Code Inspections

IntelliJ type करते समय problematic code को लाल (errors) या पीले (warnings/suggestions) में underline करता है, और Alt+Enter इनमें से कई के लिए quick-fixes खोलता है, जैसे कोई missing import जोड़ना या किसी expression को सरल बनाना।

उदाहरण: Using Code Inspections

markup
// Entry point: execution of the program starts here
fun main() {
    // Declare a read-only variable `message`, set to `"IntelliJ suggests fixes with Alt+Enter"`
    val message = "IntelliJ suggests fixes with Alt+Enter"
    // Print `message` to the console, with a trailing newline
    println(message)
}
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. यह मान लेना कि किसी Kotlin project को हमेशा IntelliJ के अंदर एक Android project के रूप में बनाना चाहिए, जबकि एक plain Kotlin/JVM project ठीक काम करता है।
  2. project बनाते समय JDK चुनना भूल जाना, जिससे IDE को compile करने के लिए कोई runtime नहीं मिलता।
  3. IDE के दिखाए लाल/पीले underlines को नज़रअंदाज़ करना और पहले flagged issue ठीक करने के बजाय code को वैसे ही चलाना।
चैप्टर सारांश
  • IntelliJ IDEA JetBrains ने बनाया है, वही company जिसने Kotlin बनाई, इसलिए इसका Kotlin support first-class है।
  • मुफ़्त Community Edition plain Kotlin/JVM projects के लिए काफी है; Android और web projects को Ultimate से फायदा होता है।
  • नया project बनाना आपसे एक JDK और एक build system (Gradle, Maven, या IntelliJ का अपना builder) चुनने को कहता है।
  • IntelliJ का built-in Run button एक click में आपका main() function compile और execute करता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

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.