I installed eclipse to work with Selenium, my code was running successfully until I restarted my system. After restarting the system and running the existing code which was save before restarting the system, it is running successfully, but Editor does not contain main type message is displayed after changing the existing code with the below simple code, could anybody please help


    package newpackage; 
    import org.openqa.selenium.*; 
    import org.openqa.selenium.chrome.ChromeDriver; 
    import java.util.List; 
    import org.openqa.selenium.By; 
    import org.openqa.selenium.WebDriver; 
    import org.openqa.selenium.WebElement;
    public class MyClass {
    public static void main(String[] args) throws InterruptedException 
    System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
            WebDriver driver = new ChromeDriver(); 
    String tagName = driver.findElement(By.id("email")).getTagName();
  • stackoverflow.com/questions/24117713/…
    – PDHide
    Commented Mar 26, 2020 at 9:15
  • Did you try all these ?
    – PDHide
    Commented Mar 26, 2020 at 9:15
  • 2
    I would suggest simply creating a makefile with the necessary commands rather than relying on error-prone and confusing IDE UI's to set up your runs. OSs don't run programs through UIs. Commented Mar 28, 2020 at 7:26
  • @JoãoFarias what is a makefile?
    – ChathuD
    Commented Mar 30, 2021 at 16:47
  • It's the script file format for Unix's Make build tool. There are plenty of tutorials out there. Commented Apr 1, 2021 at 11:29

1 Answer 1


You can try any or all of the below mentioned points to check and resolve the issue.

  1. Check if your project is a Java Project and not a General Project.

  2. Ensure that your class file (.java file) is inside the src folder.

  3. Verify that your folder in which the code (.java) is written is identified as source folder.

3.1 Got to Properties by right clicking on the project folder.

3.2 Choose Java Build Path.

3.3 Click on Sources tab.

3.4 Click on Add Folder on the right panel.

3.5 Select your folders and click Apply to save the changes.

  1. Clean Up and Refresh your project in Eclipse.

4.1 Right click on project folder.

4.2 Point cursor to Source and then click Clean Up.

4.3 Click Next and then Finish in the clean up window.

4.4 Again right click on project folder and then select Refresh.

  1. In your class/code remove the line public static void main(String args[]) and save the code. Then again add the line and save the project and repeat steps in point 4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.