Help? Edited default "new class" template and now can't create any classes.

I'm new to IntelliJ IDEA, so I hope you'll forgive what I'm sure is a silly question.

I created a new class, hit "alt+enter", and wrote in my own default class beginning. The new template I saved was just a few comment lines with my name and such. Now, though, when I try to create a new class, I get the following error message:

Unable to parse template “Class"
Error message: This template did not produce a Java class or an interface
package
PACKAGE_NAME;"some words"public class
Classname {
}

Where "some words" was the body of the new default class template I saved, and Classname is the name of the class I am now trying to create.

If only I could create a class, I could select the opening text and press alt + enter again, and put it back to the way it was, but since it won't let me create a class, I don't know how to reset the template.

What I have done:
-Went to file --> preferences -->  editor --> File and Code Templates, and I can see the original class template (I think?). But it's unchanged by the messed up version I wrote and saved.
-Completely uninstalled and reinstalled.
-Invalidated Caches / Restart


I can't create any classes now and I can't seem to fix the error. Does anyone know how to fix this?

Thanks so much.
-Veggies
2 comments
Comment actions Permalink

Ok, I found that somehow by pressing the keys that I did to edit the default words that appear at the top of a new java class, I actually edited the "file header". At least, I found my erroneous creation under "file header", and not "java class". I deleted its contents and now I am able to create classes again. Hurray. Now to figure out how to restore the original contents...

0
Comment actions Permalink

This also happened to me - I think it must be a bug that under some circumstances all the template information is deleted.    The easy way to get it back without losing all your other settings is to install another version of IntelliJ a – pick a version which is similar but not the same. Then because it's a different program you can open the templates in both versions and copy across what has been lost. 

This is also useful if you have mistakenly updated to 2017 and can't cope with the new (very slow)  performance... I use AHK to write most of my code - 2017 Is simply too slow to respond to the macros that work perfectly into 2016. 

   

0

Please sign in to leave a comment.