Eclipse Mars: code is gone - java

Please, help! I opened Eclipse Mars to continue coding and my code is gone! I don't know what could have caused this but it's all gone. Does anyone have any idea what can I do?
Note: I tried to right-click the java file->Replace With->Previous from local history. But a message says "No local history available for selected resource". Is there any other way?
Thank you in advance!

The first step in debugging this problem is to find out if the code is still exists without using Eclipse. Several possibilities come to mind:
The code is still where you expect, the files exist and the content is OK.
The code is still where you expect, the files exist, but the files are empty.
The workspace directory does not exist any more.
You need to use a file explorer program to find the files and check they are not empty. Try opening them with Notepad++ or similar. If you are lucky, option 1 will be the answer, and Eclipse has got confused. Just use File/Switch Workspace to set the workspace to the directory and all should come right.
Options 2 & 3 indicate you have lost data. There is probably little chance of recovery. Revert to your backups (you do have them?). Otherwise learn a lesson and set up a GIT or SVN server (or subscribe to a cloud service). I just use a very old laptop running Ubuntu with SVN server installed.
As a side issue, Eclipse does not randomly delete or empty files. There are millions of developers world-wide using Eclipse, and if it existed, such behavior would be all over the internet.

I had the same problem and found my file with a strange name in local history with this path:
".metadata/.plugins/org.eclipse.core.resources/.history/"
It was not the last version but better than nothing :)

Related

Access denied to java executable on target file while building project with IntelliJ

I have a multi-module project on IntelliJ Idea (version 2021.1.3).
If I try to compile my module using command line (e.g. mvn clean install), the compilation goes fine.
However, if I try to Build the project via IntelliJ (which is a preliminary action to debug a unit test, with the IDE configured the same way than the command line - meaning same JDK, same Maven home, same Maven settings and local repository), then I get the following error coming from the O.S. (I guess that because the message I receive is in French, which is the language of my O.S.):
(Sorry I'm obscuring paths for privacy reasons, but I guarantee you is not relevant).
And the console error is:
java: D:\<path>\target\classes\<path>\rest-services.json (Accès refusé)
Where "accès refusé" is French for Access denied.
Note: unfortunately I cannot really include any debugging issue neither to provide a way to make the issue reproducible on someone else's side. The only purpose of this question is to find (if it exists) THE answer from someone who went across the same issue and found a way to solve it, so that when in the future someone looks for the same keyword - me included if I have this same problem in one year and will have by then forgot what I did to workaround it - will find a specific answer that can spare them 3 hours walking in the darkness.
So, this file gets copied from src/main/resources folder inside target over the build, but then the build itself tries to access it and apparently IntelliJ gets access refused by that.
The attempts I did based on similar threads I found around:
I updated my IntelliJ Idea to the latest release
I removed the file manually from the folder and relaunched the build (the file gets copied again and then access denied again)
I completely cleaned and re-build by project with Maven before trying again
I have run IntelliJ Idea with admin rights
I have File / Invalidate Caches / Invalidate Caches and Restart multiple times on IntelliJ
I have restarted my laptop
I have checked with Windows Process Explorer and the file is not locked by anyone
I have deleted and rebuilt the test configurations of IntelliJ
None of the above worked.
Finally, I ended up being able to make it work by checking-out the guilty file in the source code into my VCS, so that the read-only flag was cleared and the O.S. ended up giving IntelliJ the right to read it.
But this is not a "solution", just a workaround, and it may happen the same with a file on which I have no ability to do so (for example a self-generated file) - plus it's strange, there are many files with read-only flag being copied from source to target (including into the same folder where I had this issue), but yet this was the only file which was causing the problem.
Does anyone ever crossed such issue and if so, how did you solve it?

Eclipse reorganizing packages and classes automatically?

I am having a strange situation where Eclipse is doing this. Here is a screenshot:
Here is the screenshot of my Github repo where updates are pushed:
Thus, I think 'src/noobchain' is the folder/package thing I want to keep and I want to delete the lower 'src' folder/package thing because it is a duplicate. It wasn't like this before, I just had the 'src/noobchain' but then Eclipse did something on its own (I know this because I checked the Edit to undo and it was greyed out).
Now when I try to delete one or the other, they both get deleted.
So I came up with possible solutions in my head now which is to do a 'git pull' to my local after closing Eclipse and then restarting Eclipse. But I'm wondering if someone else experienced this odd behavior by Eclipse Photon on Ubuntu 18.04.
I did as Goibniu suggested above by right clicking on src and then build path->use as source folder and I ended up with:
It looks weird with two sets of the classes but I can run it so no complaints I guess.
When I try to delete the src it tells me it contains a Java source folder, it will delete the source folder as well. Thus, I guess I have to leave it alone. Not a perfect answer but it works. If anyone has a better solution, please post.

Cant find Packages in Eclipse

Recently I have been working on coding Minecraft mods. Yesterday i updated to a 64 bit version of Java, and I began to receive an error that said something of this nature: "Java returned error = 13". I looked around, and discovered that my Eclipse was not 64 bit, so I went to Eclipse, and downloaded the latest 64 bit version. I then replaced my normal eclipse folder with the new one, and it launched fine. However, when I open Eclipse, (I open the exact same workspace as I did before all of this happened), I don't see anything in the Package Explorer view. Nothing at all. Typically it says MDK Example or something like that, and within that are all of my packages, etc.
Here is my question: How can I make it to where I see all of my files in the package explorer like they used to? I am using the same Workspace...
Just a warning: I code a lot, and I believe that now I'm quite skilled at it, however I am not good with computers themselves (hence why I find myself in this predicament). If I need to completely start over, I can, and I can copy over my code. It would be a nuisance but if that is all that is left to do I will do so.
Thank you for reading! Please help if you can :)
I remember encountering a similar problem after having switched the location of my workspace.
Try the following: Choose a different location for your workspace and then choose File>Import>General>"Existing Projects into Workspace".

Cannot convert project... Premature end of file error in Intellij IDE

I am using Intellij IDEA as an IDE for running Java programs. Dues to power fluctuation computer got restarted. Now when I launch the IDE after reboot i am getting the error Cannot convert project: /home/aniket/IdeaProjects/JavaDemoCodes/.idea/workspace.xml: Error on line -1: Premature end of file.
Has anyone encountered this situation before? What can I do to view my project back again?
I also had this after a power failure, I simply deleted the workspace.xml file from the projects .idea folder, restarted IntelliJ and it seemed to be OK apart from loosing which files were open.
Cheers,
Nick
I had this exact error when my laptop bluescreened. I solved it by:
Exit IntelliJ IDEA
Rename .idea folder
Start IntelliJ IDEA
Create new project from existing sources
Exit IntelliJ IDEA
Copy all files from old .idea folder to newly created one.
Restart IntelliJ IDEA
Finally solved the problem. Hers is the solution. First of all I had two Intellij IDEA projects open in two separate windows.
One was the project which had corresponding subversion repository. This was a file-based format project. Files that define a project are .iws, .ipr and .iml. .iws is the one corresponding to the workspace configuration. I just reverted back this file with svn revert project.iws and I could launch my project again.
But the problem in second project JavaDemoCodes still persisted as it was custom project I created and it looks by default we get a directory-based format project instead of file-based format project. This has all its configurations in /home/aniket/.IdeaIC12 directory. As many of you suggested i searched for workspace.xml here but could not find it. I tried find . -name *.xml but i still could not find it(Also as the error suggests there is no file /home/aniket/IdeaProjects/JavaDemoCodes/.idea/workspace.xml ).Finally I did import project from my first project(the one with svn repo) it detected my JavaDemoCodes project as Intellij IDEA project and let me open it in new window.
Not sure if this is the perfect answer but it solved my problem and yes as someone suggested I deleted .iws file from my 1st svn repo based project and tried to restart but was of no help. New .iws file was created but it still gave me the same error.
I have experienced this same problem. It happens to me when I have IntelliJ open and for whatever reason (usually problems with having multiple VPN connections open), my computer freezes and I have to do a forced re-boot.
My solution is to use Windows 7 restore. I'll go to the folder it is complaining about, right click on it, and do a restore. If I'm lucky, I have a restore point only a few days old.
For me, rebuilding my configuration on several projects from scratch is too time consuming. Using a restore point from a few days or even a week makes more sense.
Good luck.
I solved it just by creating a new project, then starting it and then reopening the old project..

PhoneGap Android "Could not find *.apk" [duplicate]

I know this question has been asked before and I have seen a plethora of solutions out there, yet none seem to work for me. I was able to build my apk without issues until this error started cropping up. I have tried cleaning my project, removing it from the workspace and reimporting it, removing "Java Builder" from my Builders for the project, building the project manually, reordering my java build path. I have no visible compiler issues and no problems exist in my workspace.
I did experience this issue before and solved it once by removing the project form my workspace and re-importing it and another time I solved it by removing "Java Builder" from my java build path. None seem to work this time. I currently have most of the settings set back to default (i.e. java build is checked again).
I am running windows 7 (64 bit) and using jdk1.6.0_21 via Eclipse 3.6.
Any suggestions would be greatly appreciated as I have lost loads of development time troubleshooting this already.
[Update] My locale is English & I have tried removing the debug.keystore, United States as related to issue 834
Please follow these steps; this might help you out:
Right-click your app project and go to Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
If your app project relies on library projects which are in your workspace, those of course need to have the "Is Library" box checked.
deleting the R.Java file in /Gen folder did the trick for me
I tried all the above solutions. but it didn't work.
The solution was to restart eclipse !!!!!!!
hope this will help someone :)
In my case this problem started after eclipse updated the plugin with the v4.0 API release. I fixed it by going to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Note: if you eclipse gives you the Unknown Command 'crunch' error then follow this post
I've tried to gather the best of other peoples answers into a step by step list of things to try in order:
Check the project is not set as a library:
Go to Project->Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
Clean and rebuild the project - this should delete and recreate the entire gen folder, including the R.java file mentioned in some peoples answers
Check eclipse and all the Android plugins are up to date
Close the project, exit Eclipse, reopen eclipse, reopen the project.
Go to Java Build Path > Projects and check for any incorrect project dependencies
Go to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Check JAVA_HOME is set correctly. Follow the steps in this article
If you complete the above list, and still haven't solved the issue, please leave a comment, or if you find something else that works, feel free to edit the answer and add your thing in.
Delete the project from your workspace & import again.
This worked for me.
Can't believe similar issue has been there since 2008.
http://code.google.com/p/android/issues/detail?id=834.
i'm no expert, but eclipse on Windows, doing android apps, refuses to create the default.properties file (in the app root directory). I've just copied one from another app and it works fine. Simple contents, for Android 2.2 project it just says (ignoring comments):
target=android-8
fwiw
I was having the same issue as the OP except that all these suggestions did not work. I found a solution for me.
Make sure that "Skip packaging and dexing until export or launch." is selected.
Go to Window -> Preferences -> Android -> Build. Just make sure that option is selected and apply.
I know this does not make a lot of sense, but having it unselected was giving me this error and with it selected it goes away and the apk is installed.
I am using the auto generated ant build script from android and ONLY using it as my build process in eclipse. I am not using any other build methods.
I figured it out. I was referencing JavaSE-1.5 and using JDK 1.6. I changed it to use 1.6 and that appears to fix it.
Seems like through my research that is an overloaded error message that covers a lot of error cases.
I just fixed this by reselecting a default JRE for the execution environment (JRE6 for JavaSE-1.6 in my case). It got unchecked for some reason.
This fixed my problem. I kept getting the console error in eclipse "Could not find com_android_vending_licensing.apk" and even though it didnt seem to effect the way my app ran, it was annoying. So going into the com_android_vending_licensing project properties and unchecking the "is library" option, building the project to produce the needed apk and then going back into the com_android_vending_licensing project properties and re checking the "is library" check box fixed the problem.
Run Eclipse as "Administrator" and then import the project.
None of these things worked for me. I'm trying to access native code through the jni, first with NDK samples. What I found was the build won't run if jarlist.cache is not present in the project bin directory. If I copy one from another project to that location (may need to refresh to see the folder in Eclipse), build works every time.
Clean the project and it will do. Sometimes it happens unknowingly but keep trying to solve using diff methods.
I had somehow done a Run configuration as a Java application instead of a Android.
the problem for me was I was trying to use IBM RAD which appears to not work properly for this, I installed Eclipse and now have a different error but I should be able to get past it
On my machine (Windows7, 64bit) I could fix this by setting my execution environment to a 32bit variant of the jdk (I used 1.6.0_23). And I tried a lot of things before...
SHA1's answer did it for me: after updating to the latest sdk/adt, my project refused to build an apk; unchecking the option resolved the issue.
I don't know if the update checked this, or if it was checked before but the new adt screwed things up, but things work again now :)
In my case this worked :
Delete R.Java file in /Gen folder
+
Delete all "R.Android" imports that Eclipse added to some of my java classes !!!
and rebuild the project.
remove -- R.java -- Clean the project and run again.. this worked for me ..
Find the project's folder in your system, enter it's Properties via context menu and deselect "Read only" option. Worked in my case.
This seems to be the source of the problem in many cases, moreover some solutions up there base on copying/rewriting the files in the project what makes them non-read-only.
This is caused by JAVA_HOME not being set correctly. It can be easily resolved by following the steps in this article.
Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:
Eclipse > Help
Install New Software
Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With'
section and press enter
After developer tools appears on the list, check it and click Next
Restart eclipse once download is finished
I my case, I had to switch from API 21 to API 19, clean and build and everything was fine again. I am using a Mac and apparently API 21 is not fully supported on Yosemite.

Categories