I wanted to add a java class to a project, but I did a mistake and added it as a text file. Then, I removed it and tried to add it again as a java class, but unfortunately it doesn't work anymore. And I get the following error:
Unable to parse template "Class" Error message: ABC.java mapped to not java file type text
As I searched, I faced some solutions like
this one but I can't find File Type
under Editor
or anything similar that I can change as suggested in the solution.
Any help would be appreciated.
PS: I am using IntelliJ 2018.3.4.
Thanks in advance,
Go on File->Settings
and a dialog will open. In that dialog navigate on the left part to Editor/File Types
and then you need to choose from the section Recognized File Types
Java Class
and remove from bottom section the problematic extension (note you have a small minus button on the right)
https://www.jetbrains.com/help/idea/creating-and-registering-file-types.html
Select required file type in top list (Recognized File Types) -- do it for "Text files" In bottom list (Registered Patterns) select undesired pattern -- "SomeFileName.java" Click on "-" (Minus) button to remove pattern from the list Repeat 1-2-3 for other undesired patterns
If desired, you can also do this manually by editing config file while IDE is closed. Because it's IDE-wide setting, it is not stored in .idea folder (which has project settinsg only) -- the file to look for is called filetypes.xml and shoudl be located in ~/Library/Preferences/IntelliJIdeaXX/options ( see http://devnet.jetbrains.net/docs/DOC-181 for other OS etc )
This is a variant of Markov's answer that worked in my scenario.
Try going to File->Settings->Editor->File Type
and to the Recognized File Types
tab. Click the "Auto-detect file type by content"
choice, and delete the name of the file you are trying to create from the "File Name Patterns"
section by using the minus button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With