Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file

I had mistakenly save my class as fileName.text file and tried to rename it with fileName .java but the IntelliJ couldn't recognize it and throws the error saying.. After spending long hours on internet, I found a solution and sharing/keeping here for future reference. Step 1: Click "File"==> "Settings" Step 2: Expand "Editor" & Click "File Types" Step 3: You will see all file types on Right. Navigate to the "Text Files" and Click it Step 4: You should able to see your file name on the bottom of Registered Patterns (lower box) Step 5: Remove your file from the Registered Patterns. The problem should solved and let you to rename with fileName.java Step 6: If not, delete the file from the project and create it again with name fileName