Eclipse not showing code in the Java Editor perspective - java

I was working in Eclipse with some packages and then suddenly the java editor perspective doesn't show any code and it's blue, just like in the photo bellow:
I tried everything, from resetting the perspective to cleaning the project, even installed a new version of Eclipse. If i select the entire content of the .java file then pass it to a txt file the code is still there.

It seems like after 2 days Eclipse just started working normal.

Just open Windows(Option at the top) --> Show View --> Console.

Related

My every project files and class suddenly turned into an strange format

Everything was good. Today, I opened Android Studio, and every kotlin class code and even layout and value files turned into another format like XML. I don't know what kind of strange reason it is.
I have been trying to fix this for 2 days now. even though I opened my files into some other editors(sublime, notepad)but the problem is still there.
I am attaching some screenshots MainActivity.kt.
I also tried these couple of things below
File > Sync project with Gradle files. Result: didn't solve my problem.
File > Invalidated cache/restart. Result: didn't solve my problem.
Try this.
Right-click on the file (e.g.: MainActivity.kt),
then click on "Open In", it will open your explorer window.
At this point open that file, which now you see in your explorer window, in a notepad, make a change (e.g.: adding a space where there is already a blank space)
and save the file.
Now Android Studio should see it correctly or, if not, try to restart Android Studio.
If that works, do the same for all suddenly-changed files.

JAVA class turned into xml file

Everything was fine. I just built it yesterday. Today, while I opened this most of my JAVA classes code, turned into xml. I don't know what kind of strange reason it is.
I tried 2 options below but nothing worked :
File > Sync project with Gradle files. Result: didn't solved my problem.
File > Invalidated cache/restart. Result: didn't solved my problem.
I attached a screenshot.
I found a solution that worked for me. Keep Android Studio open and go into the file system. Open every java source file and all xml files into some editor(Notepad++) and change something then save the file back to origin.
Now Android Studio detect all files as normal
Android studio: Click on malfunction file then Right-click -> Open in -> Explorer.
Choose your file where was the problem and open them with Notepad.
And change something, like adding the space and save it.
And Sometimes Android studio turns files into UTF8-BOM. It needs to change to UTF-8. You may do with NotePad++ -> Encoding.

Android Studio java syntax highlighting not working

In android studio's (Version 1.1.0) I'm having issues getting it to highlight .java syntax properly. It is currently only highlighting Keywords, Comma, Semicolon, and comments. Other files types such as .xml are highlighting properly.
I've tried the following things...
Reinstalling Android Studio
Removing any personal settings
In "Settings -> Editor" Changed the colors to anything to see if it
worked, under General and Java
File -> Invalidate Caches
Under File Types I've declared my file as a Java source file.
Made sure Power Save Mode was turned OFF.
I ran into this problem today. In my case it was caused by Android Studio changing my "MainActivity.java" file from a Class to a Singleton.
If the file is a Class its icon in the editor or project listing will have a "c" in a light blue circle. If it is a Singleton it has a "j" in a grey rectangle.
To resolve it I did the following:
copied the file's contents into notepad
deleted the singleton file BUT I did not select "safe delete" since I don't want Android Studio to do anything clever
created a new Java Class file with the same name as the original file
replaced the contents of the new file with what I put into notepad in step 1
Then everything started working again.
Before this I'd tried the invalidation/restart and disabling power save mode but they did not work for me. I even tried rebooting my computer several times.
The .java file was located in the root directory. I moved the file to "src/main/java/org.we/" and it the syntax started working.
You should do invalidate caches and restart. It will work.

Eclipse Luna - Project is not showing up - Strange

I just installed Luna. I imported 3 projects all went well for a while.
Then I restarted eclipse and now it shows only two projects. I tried to import the missing project, but it says it already exists in the workspace.
I closed all other projects and pressed Ctrl+Shift+T to see if it still shows up the types from that invisible project. Yes, it shows files from that invisible project. I opened one of the files and selected Show In Project Explorer. Nothing happens.
Also, in the code when I press . after an String object, nothing shows up.
Seems to be strange. Any help?
Also, if I can do fresh import of all projects, that would help too. But again, I don't know why context assist is not working. I can try importing everything afresh. For this, what are all the eclipse related folders / files I need to remove?
Edit
this helped me with workingset / missing projects. But when I press . after an object, nothing comes up.
For others benefit, it has to do with Working sets. You can click Down arrow in Project Explorer and select "Edit Active Working Set". In the window, on the left hand side, you can see your non-visible projects and move it to right hand side to make them show up under active working set. HTH.
Regarding the problem where Eclipse says it "already exists in the workspace": I recently had a similar problem and I fixed it by unchecking the box that says "copy projects into workspace" and then hit refresh and it should work.
Just fixed this issue by clicking 'Deselect working set' ( under dropdown in project explorer ). For me, 'edit Active working set' was disabled to start with.
It sounds like the projects exists on the file system in the workspace directory, but the actual project got deleted or never imported in the eclipse workspace. Take a look at the workspace directory, all three projects should be there. You can delete the "missing" project from the file system and reimport it again.

No syntax highlighting in eclipse for java

There is no syntax highlighting in java files in my eclipse..This happened all of a sudden..Not sure why..
This is how it is looking now..
As mentioned in other posts..i tried to change the color from preferences window and there is nothing when i type java..something really messed up...
AAny suggestions..
Update:
It seems Java plugin is not installed..as per the below screeenshot
And when i try to install java plugin it says new version is already installed as per the below screenshot
Closing the file's tab and re-opening it fixed it for me.
(I actually closed all the tabs...)
I faced the same issue all of a sudden after a commit/update project operation.
The point is, default editor of Eclipse has changed somehow and we have to set it back to normal.
Try the below method,
1. Goto Windows -> Click Preferences
2. From the Preferences window goto General -> Editors -> Click File Associations
3. You can choose the default editor for *.java files here
When I first opened Preferences, 'Text editor' was set as the default editor for .java files and then I changed it back to 'Java Editor'.
Now it works perfectly fine.
You probably have a corrupt installation or you have recently installed a corrupt plugin.
The following steps might help.
In your Install window,
view your "already installed" plugins.
select the "Installation History" tab.
select a previous stable configuration
Click the "Revert" button
TLDR; open another workspace, then come back to the original workspace.
Ok this is odd, but for me, all the highlighting suddenly went away for Java files. I explored all of these ideas here, with no effect. I created a new workspace, planning to move everything to it. I realized that can be a pain to move many projects over, so I went back into the original workspace to look at some settings, and poof - the highlighting was working again.
I have one java class file like a text editor.
I tried following,
Select the respective java class file from eclipse.
Right click on the file and mouse hover on "Open with".
Select java editor.
Now its works.

Categories

Resources