Java
Completed
-
Section 1: Getting Started
-
Section 2: Core Syntax
-
Section 3: Object-Oriented Java
-
Section 4: Collections Framework
-
Section 5: Exception Handling
-
Section 6: Generics
-
Section 7: Functional Java
-
Section 8: Concurrency
-
Section 9: I/O and NIO
-
Section 10: JVM Internals
-
Section 11: Modern Java Features
-
Section 12: Build Tools and Project Structure
-
Section 13: Testing
-
Section 14: Databases and Persistence
-
Section 15: Networking
-
Section 16: Design and Best Practices
-
Section 17: Reflection and Annotations
-
Section 18: Logging and Diagnostics
-
Section 19: Date, Time, and Internationalization
-
Section 20: Java Platform Module System
-
Section 21: Security in Java
-
Section 22: Advanced Collections and Data Structures
-
Section 23: More Concurrency Patterns
-
Section 24: Compression, Files, and System Integration
-
Section 25: GUI Programming
-
Section 26: Practical Projects
-
Section 27: Data Structures and Algorithms
-
Section 28: Interview and Algorithm Practice
-
Section 29: JSON and Data Interchange
-
Section 30: More Concurrency Utilities
-
Section 31: More Collections and Streams Practice
-
Section 32: More File and System Programming
-
Section 33: Standard Library Deep Dive
-
Section 34: More Practice and Drills
-
Section 35: More Testing and Quality
-
Section 36: More Design Patterns and Architecture
-
Section 37: Career and Ecosystem
-
Section 38: More OOP and Architecture Practice
-
Section 39: More Enterprise Concepts
-
Section 40: Advanced JavaFX
-
Section 41: More Interview Practice
6: Setting Up IntelliJ IDEA for Java Development
You've probably already installed IntelliJ IDEA, written a few lines of code, and then hit a wall. It's a rite of passage. You look at your screen and see something like this:
public class Greeter {
public static void main(String[] args) {
System.out.println("Ready to go!");
}
}
The code is syntactically perfect. There isn't a single missing semicolon. But in IntelliJ, String and System are highlighted in bright red. When you try to run it, the "Run" button is either greyed out or you get a vague error saying "Project SDK is not defined."
Why your code is red even though it's right
When this happens, it's rarely a problem with your Java knowledge; it's a communication breakdown between the IDE and your computer. IntelliJ is a powerful editor, but it's just an editor. It doesn't actually "come with" Java. It needs to know where the Java Development Kit (JDK) is installed on your hard drive so it can use the standard libraries to understand what a String actually is.
If the Project SDK isn't set, IntelliJ is essentially guessing. It sees System.out.println and thinks, "I've never heard of a class called System," because it hasn't been told which version of the Java library to look at.
Connecting the Engine to the Editor
To fix this, we need to point IntelliJ to your JDK. I've found that the fastest way to handle this is through the Project Structure menu. Go to File > Project Structure (or press Ctrl+Alt+Shift+S if you want to feel like a power user).
- On the left sidebar, click Project.
- Look for the SDK dropdown. If it says "No SDK," that's your culprit.
- You can either select a JDK you've already installed from the list or, even easier, click Add SDK > Download JDK.
- I usually recommend the Amazon Corretto or Oracle OpenJDK distributions—they're stable and industry standards.
Once you hit "OK," you'll notice the red text vanishes almost instantly. The IDE has finally "indexed" the library, and now it knows exactly how String and System behave.
Taming the Auto-Imports
One of the things that drives me crazy when I start a new project is having to manually type import java.util.ArrayList; every single time I use a list. You don't have to do that. IntelliJ can handle the imports for you while you type.
Go to Settings > Editor > General > Auto Import. Check the boxes for "Add unambiguous imports on the fly" and "Optimize imports on the fly." Now, when you type ArrayList and hit Enter, IntelliJ will silently add the import statement at the top of your file. It keeps your code clean and saves you from a lot of tedious typing.
Using the Gutter to Run Code
You'll see a lot of tutorials telling you to find the "Run" menu at the top of the screen. Honestly? Forget that. Look at the "gutter"—the thin vertical strip to the left of your line numbers. Whenever you have a public static void main method, a small green play arrow appears right next to the line number.
Click that arrow and select Run 'ClassName.main()'. This is the fastest way to launch your program. The first time you do this, IntelliJ creates a "Run Configuration" for that specific class, which is why you'll see it appear in the top-right dropdown menu for subsequent runs.
📋 Practical Task
Building a Currency Converter Project
Now it's time to verify your environment is fully configured. Instead of a simple print statement, you are going to build a small project that utilizes external classes to ensure your SDK and auto-imports are working correctly.
Your Goal: Create a new project in IntelliJ and implement a CurrencyConverter class.
- Project Setup: Create a new Java project named
CurrencyConverter. Ensure you have selected the JDK you configured in the lesson. - Implementation: Inside your main class, use a
java.util.Scannerto take a double value (the amount) from the user via the console. - The Logic: Multiply that value by a fixed exchange rate (e.g., 1.1 for USD to EUR) and print the result.
- Verification:
- Ensure that
Scanneris automatically imported (or manually imported if you prefer) without any red text. - Run the program using the green play arrow in the gutter.
- Verify that the output displays correctly in the IntelliJ Run tool window at the bottom.
- Ensure that
There are no comments for now.