Create a class in Eclipse

Posted in Environment Setup, Java By Raj On November 18, 2017

In my previous article, I have explained how to create Java package using Eclipse, In this article,  I am going to showcase you how to create a new Java class in Eclipse, you can create a new class by using Eclipse New Java Class Wizard

The Java class can be created in different ways in Eclipse, you can

                                                        Go to File -> New -> Class

                                                                           ( or )

                                                       Right click on package folder and select New -> Class

                                                                            ( or )

                                                        Click on Class icon in the toolbar


In the New Class Wizard fill the following fields

  • The Source Folder and Package details are automatically populated but, you need to ensure that both are pointing to correct folder’s 
  • Enter the class name in the Name textbox – HelloWorld
  • Select the appropriate modifiers for your newly created class – Public
  • Enter the superclass or use browse button to select
  • Enter the interfaces or select add button 
  • Select the stub’s checkbox, here I am selecting public static void main method
  • Select the comments checkbox, if you select, it will automatically add comment’s


The newly created class should appear in the package explorer and in the editor you should see the code