简体   繁体   中英

Eclipse Class File won't open in java editor?

I've been using eclipse a very long time but I've never encountered this problem.

I have a program I'm working with, and normally to navigate between class files you can simply double click the class file under the project explorer, or you can right click and select open with java editor.

This is fine, but randomly, I have a single class file that when you try to do this, nothing happens. If you select open with text editor, the file opens, but it won't open in java editor. Anyone experienced this?

I fixed it by copying the class file. The duplicate opened normally. Thank God.

Q: You have an Eclipse Java project (or J2EE project), correct?

Q: Most of the .java files in your project open with the (context-sensitive) Java editor, correct? And most of the .class files already compiled in your project open with the "Java decompiler", showing the Java byte code instructions for that class, correct?

Q: The problem is that some of the .java (source) and .class (byte code) files don't behave this way, correct? When a file goes "bad", is it always broken for both .java and the corresponding .class file?

SUGGESTION: Try Project, Clean; then "Project validate". See if one or all of the affected files "recover".

Close your eclipse IDE and compile the project from terminal or CMD using mvn clean install -U -DskipTests=true.See if you get any error in compilation then fix it(usually it is due to some indentation error which by mistake got added in java file),if not just lauch your eclipse IDE and open the corrupt java file,it should open this time without any issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM