How to access the same eclipse workspaces from different OSs? - eclipse

I have couple of different OSs installed. When I try to start eclipse in another OS eclipse starts complaining about workspace being used by 'another eclipse instance'. In case you don't know eclipse uses .lock files for that.
How to fix this?
I see a couple of possible ways to deal with this problem:
Disable .lock file check (It can cause some problems if opening workspace in 2 eclipses at the same time)
To make an empty 'workspace' just to make eclipse happy about all that settings and .metadata and .locks and keep projects elsewhere.
Removing .lock file every time I boot another OS. But what if I'll make a new workspace?
Is there a standard (or just better) solution of this problem?

If you exited Eclipse cleanly, then it should not complain about the Workspace being used.
Or do you want to access a Workspace with multiple Eclipses simultaneously?
UPDATE: Anyway I did this on a Mac, using the same Workspace on a FAT32 partition from OSX, Ubuntu and Windows, and I didn't encounter many problems. Of course remember to set the file encoding and line termination setting project or Workspace wide!

Eclipse workspaces are not designed or intended to be shared across different machines (nor across different operating systems). Trying to do so is certain to cause headaches and possibly even corruption of the workspace. There are things like absolute file paths (and other artifacts) embedded into workspaces that simply are not portable.
The better approach is to locate the projects elsewhere in the file system outside of the workspace; that way you can have multiple workspaces "contain" the project(s). Creating such a project is easy from the project creation wizards (a checkbox labeled like "Use default location" that needs to be un-checked, and an accompanying field that is filled in with the desired files system location). From another workspace, use File > Import > Existing Project Into Workspace to get the project in.

Related

Eclipse crashed and deleted all my work

Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
Is it possible to force Eclipse or JVM to use trash can, so that if it goes mad and delete everything, files could restored.
UPDATE
Files were definitely wiped out. This was checked with third party file managers. Also entire disc were searched for traces.
Some good news is that Eclipse history remained. This allowed to restore some files I changed from Eclipse. But this project was consisting of multiple other files, that were written not by me (taken from other libraries) or contained some data I was editing not in Eclipse (like XML or raw data).
All these files were wiped out by Eclipse.
If this would not happen to me I would also say it is unlikely. But it has happened.
The problem is somehow related with
(1) Eclipse
(2) Maven (m2e)
(3) Eclipse RCP
(4) Tycho
At some moment Eclipse started to show numerous error windows and I was to kill the process. After that I found files absent.
So I need some extra protection layer.
UPDATE 2
Crash repeated. This is a message during file wiping out:
This time I was not using Maven and Tycho.
UPDATE 3
Third crash.
Crash occurs only after error Application ... could not be found in the registry, which itself buggie.
UPDATE 4
Still unable to reproduce situation from scratch...
UPDATE: I think from this question you were working on an Eclipse RCP plugin or something like that when this happened.
So you probably broke your Eclipse in some fashion. Do not trust anything Eclipse tells you at this point! Look at the actual filesystem!
Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
That's highly unlikely. (Especially if those XML files were not in the workspace. But even if they were, it's very unlikely.) You probably opened a new workspace without realising it, or maybe Eclipse has some bug where it won't show you files that are actually there. Or maybe you accidentally switched to the wrong view (in Java the normal view for files is Package Explorer, if I remember correctly).
Or maybe you were storing your workspace on a USB stick (aka pen drive) or network drive and you accidentally disconnected from it without realising it.
Check in the workspace (the actual workspace you were using at the time, not the workspace you are now using, which, as I said, might not be the same thing), using Windows Explorer (if you are using Windows) or Finder (if you are using a Mac) or using ls (if you are using something else). Are the files really gone?
This Was My Fault
I was setting up a workspace location pointing to project folder and also setting clear workspace checkbox.
::shame::

Can different IDE share a same workspace?

I would like to use Eclipse and Spring Tool Suite at the same time using the same workspace.
Is there a way to do that?
PS: I've tried deleting .lock file in .metadata directory. But after I open Eclipse again, it's regenerated.
Thanks in advance!
No, it is not possible. The workspace stores several piece of information that both IDEs require (e.g. the Eclipse file system model that stores the list of all projects).
There are two things you could do (if you really require to work with both components):
Install every plug-in of one of your IDEs into the other (presumably it would be easier to install your Eclipse plug-ins into STS, but it very much depends on what you have installed). Then, if you need, you can open two windows (Window / New Window from the main menu), and then manage your stuff as needed.
Maintain two installations with two different workspaces, that share a set of projects stored outside the workspace. However, I would not recommend this approach because
You have to refresh the projects in the other workspace (where you were not editing)
The automatic builders registered in both workspaces would execute much often, and even worse, they could be conflicting with each other.
If you only need to work with the same set of versioned projects in the Eclipse instances, then maybe it would be a better idea to create a Team Project Set of your projects, and check them out into both workspaces, and share your changes through the version control system.

How to keep an Eclipse installation in sync between multiple platforms with Dropbox?

Setting up Eclipse on each machine I work it a real headache and I want to keep the Eclipse files and configuration in-sync between several machines.
I want to keep Eclipse in sync on OS X, Linux and Windows so I started getting the OS X version of eclipse because it has the app needed for OS X, as for the other two platforms it's easier to launch it.
What questions/problems I have:
What should I not sync?
Where can I put JDBC jar files so they are synced too? Is there a way to load them using a relative path?
Any success stories?
Note: this is not about getting the projects themselves in sync, for this there are all blends of SCM.
You can not share the Eclipse installation directory or the workspace, but the projects themselves are easy to keep in sync using a version management system like cvs, svn, git, etc. I suppose you could store your project contents in a Dropbox folder (or similar file system syncing mechanism) and then just force Refresh when you sit down at a machine that was using those projects, but I've never tried it and would be wary that human error could lead to lost work or corruption of files.
The key is that, although workspaces themselves can't be shared, projects don't have to be located physically under the workspace folder on your file system. That's because the workspace is a logical container for projects, not necessarily a physical container. When creating a project you can specify an arbitrary file system location for the project contents. The default just happens to be under the workspace location. SO on each machine you'd have a separate workspace that imported the project(s) from wherever you are syncing them on your file system. That way the workspace is a tiny container that doesn't require much ongoing maintenance on each machine. I do this locally all the time - I have multiple workspaces on my machine, some of which include the same projects as others.
Most of the configuration of Eclipse is in the Workspace. And unfortunately, all the files in it are platform specific. I've tried doing something like this myself and had no luck. Asking questions in their IRC channel didn't leave me with hope either.

Why does the Eclipse Package Explorer show the projects from two different workspaces on my Mac?

I've discovered a curious thing on my Mac. At some point I apparently created two different Eclipse workspaces, one in /Users/username/workspace and the other in /Users/username/Documents/workspace (this may have happened as a result of some troubleshooting a while ago). I never knew until now that anything was amiss because the contents of both workspace folders are visible in the Eclipse Package Explorer.
I only just noticed because I'm trying to use Mercurial from the command line and couldn't find the project folder to create a repository. After some cursing I found the other workspace. The other strange thing is that from Eclipse's perspective, projects from both workspaces appear to be housed in /Users/username/Documents/workspace, even though some projects are only in /Users/username/workspace.
I believe the problem itself is easily solved (import things from one workspace into the other) but I want to understand why it is happening, and haven't been able to find anything about it elsewhere. My suspicion is that this is being caused by metadata that is telling Eclipse about the workspaces in both locations, and / or some Mac file system magic. However, I'm not sure where to start looking. Where I should begin? What might be causing this?
First, I personally prefer Eclipse to present me with a combo-box allowing me to select the workspace to be opened. You can set it in the preferences, under General -> Startup and Shutdown -> Workspace.
If you prefer not to be asked, you can specify the workspace explicitly in the eclipse.ini file (inside the Eclipse.app package) by using the -data switch (more about Eclipse.ini: http://wiki.eclipse.org/Eclipse.ini#Mac_OS_X_Example, all the switch options are in the Eclipse help).
Projects are not required to be inside the workspace. I like storing my work outside the workspace, since I usually share projects between workspaces. When creating a project, you can specify a location which is different than the default location. You can see the location of the project by right clicking it in the Project Explorer and selecting Properties.

Eclipse and copying workspaces

What do I have to do to copy a complete workspace from one computer to another and be simply able to continue working on it on the other computer?
In general, a filesystem copy should be sufficient. If you run into problems with your projects, try removing the project from the workspace (without deleting the files) and then re-add the project, which will rebuild the metadata.
Make sure you shut down eclipse before you copy the workspace, and that the target computer has the same (or higher) eclipse version, including the same plugins.
Check that your workspace actually contains all the projects - when creating a project, it's possible to have its files situated outside the workspace.
If your projects use any external libraries installed on the system, install these on the other system in the same place (or adjust the paths).
Then, there should be no problem.
You shouldn't have any issues with a straight filesystem copy as long as your eclipse versions match up.
If they don't, the project metadata may not load correctly
You need to copy the whole folder which you select as your workspace at startup (or you once selected). All settings are included in there (even the opened files).
I use rsync for this. Works great.