Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve java file mapped to not java file type text

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,

like image 702
user1419243 Avatar asked May 09 '19 12:05

user1419243


Video Answer


3 Answers

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

like image 106
Borislav Markov Avatar answered Sep 28 '22 03:09

Borislav Markov


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 )

like image 36
Ajay Reddy Avatar answered Sep 28 '22 03:09

Ajay Reddy


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.

enter image description here

like image 35
Alexander Summers Avatar answered Sep 28 '22 05:09

Alexander Summers