This issue comes. when the project directory in which the package is present, over there TestNG is not present. Make sure to follow the hierarchy wrt src folder being inside the project directory, and .java files and .class files will be automatically created as per your structure.