Reputation: 6562
When I start, Eclipse says "Workspace Cannot Be Locked"
"Could not launch the product because the associated workspace is currently in use by another Eclipse application." or “Workspace in use or cannot be created, chose a different one.”
But I know it isn't.
How do I "unlock" it?
Upvotes: 341
Views: 275911
Reputation: 111
For Ubuntu users
ps -ef | grep java
above command will give you PID for the running java instances, once you have a PID. kill the PID with following command
kill -9 <pid>
Upvotes: 0
Reputation: 914
In my case, there was a space right before the workspace's location C:\
. I removed that space and it was enough :)
Upvotes: 0
Reputation: 531
If anyone have come here with a STM32Cube related issue, which apparently is based on Eclipse and has the same problem, none of the above suggestions worked for me, and here is how I fixed it, for Linux, although I suppose you can find the corresponding paths in Windows as well.
In the $HOME
directory, go to .eclipse/com.st.stm32cube.ide.../configuration/settings
The file org.eclipse.ui.ide.prefs
contains few options including the recent workspace path, and whether it will prompt you to select a workspace at the startup. Either modify the path for RECENT_WORKSPACES
, or enable SHOW_WORKSPACE_SELECTION_DIALOG
.
Upvotes: 1
Reputation: 56
What worked in my case was restarting the system. (ubuntu 20.04)
Upvotes: 0
Reputation: 139
It seems your workspace is used in Java TM, Open task manager and close eclipse.exe and java TM process.
Upvotes: 0
Reputation: 901
I faced the same problem, but for some reasons the .lock
file in workspace was not getting deleted. Even creating a new workspace was also getting locked.
So what I did was cleaning the windows temp
folder, the %PREFETCH%
folder and %TEMP%
locations. Restart the system and then it allowed to delete the .lock
file.
Maybe it will help someone.
Upvotes: 0
Reputation: 417
The reason this was happening to me (with Photon) was easily fixed by changing an Eclipse general preference:
Window -> Preferences -> General: Uncheck: "Always run in background"
Once you make that change, whenever you shutdown Eclipse, it will no longer leave the javaw.exe process running in the background. I’m guessing this is a bug in Photon (or a bug with using the Amazon Corretto OpenJDK version of Java with Eclipse) that will one day be fixed.
Upvotes: 0
Reputation: 463
Start Eclipse with the option -Dosgi.locking=none
.
I got the trick here and it works.
Don't do this unless you know nobody can work on the same file at the same time.
Upvotes: 2
Reputation: 3564
I don't know what's the wrong but I solved by creating a directory directly in c drive(c:\dev) instead of from my home folder (c:\users\me\dev). But I don't have to thinks about it. In my case, it is fresh eclipse unziped instance. I am not able to see .matadata folder in eclipse folder. By God grace, I solved.
Upvotes: 0
Reputation: 130
For Mac Users:
It could be that another instance of eclipse is running in the background. If so, use either Force Quit eclipse or
ps -ef |grep eclipse kill -9 pid
to all the eclipse instances, and start the new workspace
Upvotes: 2
Reputation: 367
i was faced this issue when ever the eclipse is not closed (kill eclipse process the from task manager or computer power off), i was tried below steps, it worked for me.
1) Remove the file names start with ".fileTable" from this folder
C:\eclipse\configuration\org.eclipse.osgi.manager
2) Remove the log files like text files start with numeric names from this folder
C:\eclipse\configuration
3) Open Command prompt(cmd) navigate to this folder
C:\eclipse
type below command
eclipse clean start
Upvotes: 2
Reputation: 2275
I have observed one case when eclipse when in forced quit, or Alt-f2 xkill
ed in linux, an attempt to immediately open eclipse shows that error. Even the metadat/.lock file is not present in that case.
However it starts working after a span of about two minutes
Upvotes: 0
Reputation: 139
It will occur when you not closed eclipse.exe correctly.
*Open Task manager->End task your eclipse->Now open eclipse.exe it will work.
Hope its help someone.
Upvotes: 0
Reputation: 7132
Just delete the .lock
file in the .metadata
directory in your eclipse workspace directory.
Precaution - If you delete the .metadata
folder all preference will be deleted.
Upvotes: 613
Reputation: 8609
Choosing a "different one" is actually a pretty easy solution.
I had been running Eclipse as an administrator (sudo eclipse
from the command line) because the "workspace" folder was throwing the Workspace in use or cannot be created…
error (and running as administrator seemed to be the only solution that fixed it).
A coworker (working on this same issue with me) wanted to run Eclipse by clicking on an icon. So when he ran Eclipse, and the dialogue box came up with the choose your workspace, he just added a "2" to the end of "workspace".
This created a new folder: "workspace2". Eclipse ran fine with that; and I haven’t had any of the locking problems since.
Upvotes: 0
Reputation: 988
I've seen 3 other fixes so far:
The solution boils down to cleaning up the .metadata folder.
Upvotes: 43
Reputation: 1
Here are a few steps to solve it the no. 4 step is works for me.
Upvotes: 0
Reputation: 31
deleting logs and .lock didn't work but
-clean option fixed it for me.
Upvotes: 3
Reputation: 1438
I had this error after I restarted the system (after a long time. Normally I just make it sleep). Found out that once I mounted the drives (by clicking and opening it) where project folder is located, and relaunching eclipse, solved the issue for me.
PS: I'm an ubuntu user.
Upvotes: 0
Reputation: 121
Another possible cause of the “Workspace in use or cannot be created, chose a different one” issue is that the real path to your workspace may have changed.
In my case, the real location of the workspace had changed, but I had used a symlink to make it look like it was in the same location. I saw errors in logs indicating that eclipse was looking at the previous "real" location, as opposed to following the symlink, and this was causing the errors.
In my case, I just moved the workspace back to its old location.
Upvotes: 12
Reputation: 7713
Another possible case if none works is to see that there is a running Java
application . may be your previous open and close has left unkilled java instances.
Do look for any java instance is running if there are two at least you need to kill one.But ,most of the time i kill any java running :) because that java is using the work space earlier and still will if don't kill it.
Change another work space in case if you want a multiple IDE to use and work on diffrent or same project , but you should import project form workspace after you open your IDE.
Upvotes: 2
Reputation: 91
Running eclipse in Administrator Mode
fixed it for me. You can do this by [Right Click] -> Run as Administrator on the eclipse.exe
from your install dir.
I was on a working environment with win7 machine having restrictive permission. I also did remove the .lock
and .log
files but that did not help. It can be a combination of all as well that made it work.
Upvotes: 7
Reputation: 1
Another problem is when eclipse doesn't have write access to your src folder. Change the security permission and make sure "Authenticated Users" are added with all permissions checked but Full Control & Special Permissions.
Upvotes: 0
Reputation: 21
At times, if you are on Windows, you may not see all the processes - or the culprit process in Task manager. I had to click 'Show process from all users' and there was this java.exe that I had to kill in order to get back my workspace.
Upvotes: 2
Reputation: 683
Another all-too-common reason for this problem is if you attempt to load a directory on a drive that is no longer connected. For example, Say you program in C:\Code\Java, but occasionally work off of a flash drive, H:\Code\Java. If you do not have the drive connected it can be easy to believe you are trying to load a valid directory without noticing your typo.
Upvotes: 0
Reputation: 3518
The answer @Boris gave is correct 99% of the time, however it can also happen if you open the workspace in an older version of Eclipse. A workspace imported into/created with Juno will throw this error when opened in Galileo.
Upvotes: 0
Reputation: 221
Go to TaskManager(Right Click in the Task Bar) and select Processess menu bar and select eclipse.exe and Click EndProcess
Upvotes: 19
Reputation: 11590
There is another case where the path to the workspace may not exist, e.g., if you have imported preferences from another workspace, then some imported workspace addresses may appear in your "open workspace" dialog; then if you didn't pay attention to those addresses, you would get the exact same error once you tried to open them.
Upvotes: 7