Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
How to Create a Maven Project in IntelliJ IDEA?
Next article icon

Creating First Java Application in IntelliJ IDEA

Last Updated : 28 Jan, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

IntelliJ IDEA is a Java IDE that is one of the 3 biggest and most popular IDE’s in the world. It has two versions, namely the free open-source community edition and a paid Ultimate edition. Some features of IntelliJ IDEA are as follows:

  • Both versions of IntelliJ IDEA support various programming languages like Java, Scala, Kotlin, Groovy, etc.
  • There are many features in IntelliJ IDEA that make programming simpler such as debugging, code completion, code inspections, XML editing support, code refactoring, unit testing, TestNG, etc.
  • Some other tools that are only offered in the paid Ultimate version duplicate detection, JavaScript and database tools, Perforce integration, etc.
  • IntelliJ IDEA can be used on platforms like Linux, macOS, and Windows

Procedure:

  1. Start a project
  2. Create a package inside the project and corresponding classes to the package created
  3. Write the code to be executed in a text editor
  4. Package the above project in JAR 
  5. Test the application
  6. Execute the above JAR file

Implementation: 

Step 1: Start a project

  • When you open IntelliJ for the first time you will get a welcome screen with three options. Out of those three options click on the new project to get started.
  • In the next window, you have to give the name of your project
    • “GeeksForGeeks” is a custom input used to illustrate here in the article.
  • If you want to use an additional library or any kind of template then you have an option to choose from the dropdown menu that will ease your task.
  • After clicking finish your IDE will create a virtual environment for your project.

  • Name the project as ‘GeeksForGeeks’ (you can choose any name), and then clicks finish.

Step 2: Create a package inside the project and corresponding classes to the package created

  • On the left-hand side of the project window, select ‘src → new → java class → write ‘GeeksForGeeks.gfg’ ‘
  • It will create a project named ‘GeeksForGeeks’ and create a class of ‘GeeksforGeeks’.

Step 3: Write the code to be executed in a text editor

 Writing a demo program in the text editor that should only print “This is my first project in java” after the program is successfully compiled and run.

Example

Java




// Java demo program to print message on the console
  
// Importing input output classes
import java.io.*;
  
// Class
public class Geeksforgeeks {
  
    // Main driver method
    public static void main(String[] args)
    {
        // Print and display on the console after
        // successful compilation and execution
        System.out.println(
            "This is my first project in java");
    }
}
 
 


  • After writing the above code you may check if it is finishing with exit code ‘0’ or not.

Step 4: Package the above project in JAR 

  • After you have finished with the writing part you can now package your application in a JAR file.
  • Select file → project Structure → artifact

  • Click on the addition sign(+) as you can see in the following image.

  • Select the folder icon that is present in the left of the output directory field and define the path to the .jar file.
  • Now go to build in the navigation bar and select ‘build artifacts‘ from the drop-down list.

Step 5 -NOW TEST YOUR APPLICATION

  • Now select Edit configuration from the field present on the right-hand side as shown below, highlighted with a yellow box.

  • Now click on the addition sign(+) and select the JAR application from the menu. In the name field write ‘GeeksForGeeksJar‘.
  • Choose the ‘GeeksForGeeks.jar’ file from the directories.

  • In the path to jar field, click the folder sign and specify the path of your .jar file.
  • Click on the plus sign(+) in the before launch field and then select build artifacts from the given options.

  • Select GeeksForGeeks: jar from the menu and press OK.

Step 6: Execute the above JAR file

  • Select GeeksForGeeks.jar from the toolbar in the top right corner of your IDE and run.
  • If the process executed successfully, it means that your application is packaged correctly and you are done with creating your first java application in IntelliJ IDEA.



Next Article
How to Create a Maven Project in IntelliJ IDEA?
author
krishna_97
Improve
Article Tags :
  • Java
Practice Tags :
  • Java

Similar Reads

  • Creating First Servlet Application using NetBeans IDE
    Servlets are the Java programs that run on the Java-enabled web server or application server. They are used to handle the request obtained from the webserver, process the request, produce the response, then send a response back to the webserver. NetBeans is an integrated development environment (IDE
    2 min read
  • How to Run Your First Spring Boot Application in IntelliJ IDEA?
    IntelliJ IDEA is an integrated development environment(IDE) written in Java. It is used for developing computer software. This IDE is developed by Jetbrains and is available as an Apache 2 Licensed community edition and a commercial edition. It is an intelligent, context-aware IDE for working with J
    3 min read
  • How to Create a Maven Project in IntelliJ IDEA?
    Maven is a powerful project management tool based on POM (project object model). It is used for project build, dependency, and documentation. It simplifies the build process like ANT. But it is too much advanced than ANT. In the short term, we can tell maven is a tool that can build and manage any J
    3 min read
  • How to Create a Gradle Project in IntelliJ IDEA?
    Gradle is an excellent open-source construction tool that is capable of the development of any kind of software. It is an automation tool that is based on Apache Ant and Apache Maven. This tool is capable of developing applications with industry standards and supports a variety of languages includin
    2 min read
  • How to Run Your First Spring Boot Application in Eclipse IDE?
    Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and se
    3 min read
  • How to Run Your First Spring Boot Application in Spring Tool Suite?
    Spring Tool Suite (STS) is a Java IDE tailored for developing Spring-based enterprise applications. It is easier, faster, and more convenient. Most importantly, it is based on Eclipse IDE. STS is free, open-source, and powered by VMware. Spring Tools 4 is the next generation of Spring tooling for yo
    3 min read
  • Eclipse Vs IntelliJ IDEA Vs NetBeans for Java Development
    IDE stands for Integrated Development Environment. It is used for developing software and projects faster because it has various tools that you require in your project like a line debugger that will keep a check of each and every line, version control like git for an easy workflow with GitHub, smart
    8 min read
  • How to Set Context Path in Spring Boot Application?
    The context path is a prefix to the URL path used to identify and differentiate between different context(s). In Spring Boot, by default, the applications are accessed by context path “/”. That means we can access the application directly at http://localhost:PORT/. For example http://localhost:8080/
    6 min read
  • How to Add External JAR File to an IntelliJ IDEA Project?
    IntelliJ is an integrated development environment(IDE) written in Java. It is used for developing computer software. This IDE is developed by Jetbrains and is available as an Apache 2 Licensed community edition and a commercial edition. Please refer to this article Step by Step guide to install Inte
    2 min read
  • Difference between a Java Application and a Java Applet
    Java Application is just like a Java program that runs on an underlying operating system with the support of a virtual machine. It is also known as an application program. The graphical user interface is not necessary to execute the java applications, it can be run with or without it. Java Applet is
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences