First look at your project structure

Updated: 3 years ago

Check out other lessons in Learning the Java syntax

We now have an empty command line template project that we'll use to create our first Java application. Before we start coding, we'll spend a few minutes learning what everything does.

Folder structure

IntelliJ startup screen

IntelliJ has created two folders: .idea and src. Inside the .idea folder, our IntelliJ settings are stored. These are are automatically generated when you change any of the IntelliJ settings or preferences, so there's no need to change them manually.

When you first run your Java application a new folder will also be created named out where the compiled machine-code is stored. This is automatically generated every time you compile your project, so you don't have to worry about it.

Inside the src our source code is stored. This is where we are going to write our Java code. IntelliJ has also created a couple of folders that correspond to our package name. In my case, inside the src folder I have a com folder and inside that one I have a codescrubs folder. Inside the codescrubs folder I have the file.

All of your Java code will be stored inside files with the .java extension.

Code structure

Now let's check out our file. While I won't go into details just yet it's still good if you at least start learning how everything works.

package com.codescrubs;

public class Main 

    public static void main(String[] args) 
         // write your code here


package com.codescrubs; tells the Java compiler that this code lives inside a package called com.codescrubs. Once you start doing more complex applications, you'll use different package names for different parts of your codebase.


public class Main tells the Java compiler that we have a public class called Main. Classes are like blueprints for objects and are used extensively in Java and other programming languages. Classes start with a capital letter and they reside in a file with the same name (


public static void main(String[] args) tells the Java compiler that the we have a method called main that's public, static and the keyword void tells us that it doesn't return anything. This method can also accept Strings (strings are texts) as input. We'll cover methods and how to use them a bit later, but for the time being imagine that methods are instructions inside classes that will do something.

So in this case we have a class called Main that has a method called main. Confusing I know, but bare with me.


\\ is a comment. A comment is text that will be ignored when you run your program. Comments are used as helpful tips or instructions for yourself or other developers and are not executed. So if you don't want to run a piece of code just put \\ in front of it. You can also use /* to start a multiline comment and then */ to end it.

Code blocks

{} are called curly brackets. They are used to create code blocks which then define the scope of our classes and methods. If you imagine code as water, curly brackets are then glasses that hold that code. {} prevent the code from spilling to the rest of the program.

In our existing project, we have two code blocks. One starts at the class declaration with the {, inside we have a method code block ({}) and then after it, we close the class code block with a }. Two code blocks, where one is inside another. The inner code block thus prevents the code from spilling out.

Now it's time to write our first Java application!