Where does Eclipse store the info about which workspace to start up with? - eclipse

When I launch Eclipse it starts with one of the workspaces I created and selected "don't ask again" (standardly, Eclipse asks about which workspace to start with during the startup).
So it must store somewhere which workspace to use. Where does it store this piece of information?

In
$HOME/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration/.settings
there is a file
org.eclipse.ui.ide.prefs
where it is stored.

With Eclipse Juno, I can see this information in:
eclipse\configuration\.settings file.
I guess you are looking for RECENT_WORKSPACES and SHOW_WORKSPACE_SELECTION_DIALOG vars.

The settings have changed since this question was posted, as newer versions of Eclipse have been released.
With Eclipse Luna, navigate to $ECLIPSE_HOME/eclipse/configuration/.settings and the file org.eclipse.ui.ide.prefs contains settings like this (Windows file configuration shown):
MAX_RECENT_WORKSPACES=5
RECENT_WORKSPACES=C\:\\src\\eclipse-workspaces\\luna\\MyApp\nC\:\\src\\eclipse-workspaces\\luna\\MyOtherApp
RECENT_WORKSPACES_PROTOCOL=3
SHOW_WORKSPACE_SELECTION_DIALOG=true
eclipse.preferences.version=1
Each entry in RECENT_WORKSPACES appears to be delimited by \n with no spaces. Whenever I manually shuffle my workspaces around (which is rare, but it happens), I've had great success hand-editing this file, saving it, and having the new paths show up just fine in the Workspace Lancher/Select a Workspace dialog.

You have eclipse configuration files in "eclipse_home"/configuration and the one you may looking for is in settings directory : org.eclipse.ui.ide.prefs

I was facing an issue with Spring Tool Suite 4. The workspace used to give an error and I wasn't able to select other workspace also. With the help of some answers already given, I could locate the configuration in $ECLIPSE_HOME\sts-4.7.1.RELEASE\configuration.settings\org.eclipse.epp.mpc.ui.prefs
I removed RECENT_WORKSPACES property (after you try to restart, it adds default entry again) and changed
SHOW_WORKSPACE_SELECTION_DIALOG=true
STS started showing workspace selection dialog again.

If Eclipse has been installed with ubuntu-make, the file location is ~/.local/share/umake/ide/eclipse-jee/configuration/.settings/org.eclipse.ui.ide.prefs.

Related

How modify Eclipse locations to prevent write to user.home directory?

I have tried all different settings, and yes, I m aware of eclipse.ini and config.ini and also tried different command line arguments! Nothing solved my problem!
All attempts and still each time I run eclipse.exe it wants write to my userhome i.e. the .eclipse and .p2 folders.
I have tried with all settings bellow among others, in different combinations too:
-Dosgi.user.area=file:/c:/eclipse-conf/e46
-Dosgi.configuration.area=file:/c:/eclipse-conf/e46
-Dosgi.instance.area=file:/c:/eclipse-conf/e46
-Declipse.p2.data.area=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.configurationFolder=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.installFolder=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.cache=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.roaming=file:/c:/eclipse-conf/e46/p2
-Dorg.eclipse.equinox.p2.cache.shared=file:/c:/eclipse-conf/e46/p2
This did not help! Well it writes to /e46 and /e46/p2 folder but it also creates/writes to c:\users\mrsimplemind\.eclipse & .eclipseextension & .p2
Even if I manually create the folders before it will not help.
Now please anyone here had success to fully isolate eclipse configuration output?
The only way I achieved this was by changing the user.home but I don't like this workaround as there are stuff in the original "user.home" that will be needed in eclipse, e.g. .ssh , .git , .m2 maven etc. I don't want to keep duplicates of profile settings for each eclipse user.home
I just want to isolate eclipse, this should be configurable! I don't like the outputs to user.home .. It is not an option! I want to have control of what eclipse creates in what folders, for each eclipse installation.
(I can only tell from windows os, I don't know how if Eclipse on Mac works better with the settings above)
I dont use OOMPH installer, some comments below are misleading
The method I have tried to solve this problem has been nearly successful. Whether this is an answer for you will depend on your minimum acceptable level of quality.
If you are trying to prevent your Eclipse IDE from filling up your home drive, this technique will work (it has worked for me). It should not matter if Eclipse was installed by Oomph or from a plain zip, as nothing Oomph-related is modified in this solution.
If the requirement is that the user home p2 folder can be completely deleted and yet Eclipse still works without recreating that directory, no I have not been able to achieve that yet.
I am posting this as a partial solution, perhaps in the hope someone else can build upon it to figure out a better workaround. Obviously the perfect solution would be if eclipse had a configurable download location and the installer actually installed all software to only the location selected, but that requires the Eclipse developers to fix the "P2" component of the product. What follows is only a workaround.
Strategy
The premise is that the download pool folder always seems to be hardcoded into the config files to be under the home folder of the user that ran the eclipse installer. The essence of this workaround is to create a fake user home folder in the location of your choice, do a massive find-and-replace in the config files, and then force the Java system property to use that new folder as "user.home" which fools Eclipse into using it for its downloads.
Method
This was tested on Eclipse 4.7 Oxygen.3A on Mint Linux.
Extensive brain surgery of the Eclipse installation folder is needed.
Install Eclipse somewhere other than your user's home drive.
In this example the Oomph installer was given /media/LINAPPS/ubuntu-apps/eclipse-oxy as the install target, which then creates /media/LINAPPS/ubuntu-apps/eclipse-oxy/eclipse during the installation.
Start Eclipse at least once, then close it and make sure Eclipse is not running.
Create a new fake user home drive folder underneath the Eclipse folder.
In this example I created eclipse-oxy/eclipse/fakeHome
Copy the entire (hidden) p2 directory from your user home directory into the new fakeHome.
eg cp -R /home/$USER/.p2 /media/LINAPPS/ubuntu-apps/eclipse-oxy/eclipse/fakeHome/.p2
Go to the eclipse folder and edit the eclipse.ini in a text editor. Make these 2 changes:
set the line after --launcher.library to be the copy of the pool in the new location relative to the eclipse folder, eg : fakeHome/.p2/pool/...etc...
append a new system property setting to end of the file after all the other vm arguments, and set user.home to the new fake user home directory.
eg: -Duser.home=/media/LINAPPS/ubuntu-apps/eclipse-oxy/eclipse/fakeHome
Edit the file eclipse/configuration/org.eclipse.update/platform.xml. Find the first <site> entry and change the url attribute to be the new pool folder relative to the eclipse folder. eg: url="file:fakeHome/.p2/pool/"
Edit the file /media/LINAPPS/ubuntu-apps/eclipse-oxy/eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info and again find and replace all references to you user home's p2 folder with the new p2 folder under the fakeUser. You could find over 1000 matches to replace here. It again seems to be possible to make these relative to the eclipse folder, so a path of "fakeHome/.p2/pool/....." will work.
Go to the new /eclipse/fakeHome/.p2 folder and edit both of the files there "pools.info" and "profiles.info". Again find any reference to your real user home and replace it with the path to the fakeUser folder. Use the full pathname (from root) for the pool location in both of these files.
Unpack, edit, and repack the latest profileRegistry. Find the folder
eclipse/fakeHome/.p2/org.eclipse.equinox.p2.engine/profileRegistry/_media_LINAPPS_ubuntu-apps_eclipse-oxy_eclipse.profile/. Now find the latest timestamped gz file in that folder. For example it might be called "1529736854441.profile.gz".
gunzip that .gz file. Edit the .profile file and again replace any mention of your real user home with the new fakeUser folder. For example in my installation one of the first property settings had to be changed to
<property name='org.eclipse.equinox.p2.cache' value='/media/LINAPPS/ubuntu-apps/eclipse-oxy/eclipse/fakeHome/.p2/pool'/>
Delete the old gz file, then gzip the profile into a gz, so it has replaced the old one.
I also edited the file /eclipse/fakeHome/.p2/org.eclipse.equinox.p2.core/cache/artifacts.xml and replaced the repository name with a reference to the new location inside fakeHome, but I am not sure this was necessary to get eclipse working.
Start eclipse.
Results
After doing the above, I tried to add Install New Software from the Help menu. After downloading lots of new plugins from Redhat and Spring, the new fakeHome pool occupies 900MB, but the original user home pool is still less than 400MB which is what it was as soon as eclipse had been installed. So it has been successful at moving the download cache of the updater and no files get updated in the old location, but two directories under .p2 still seem to have their timestamps touched.
If anyone finds this useful, or figures out how to improve it, please let me know.
This works on Windows 7, Eclipse Oxygen:
Install Eclipse, but DON'T launch it yet
Edit eclipse.ini and, underneath -vmargs, add an entry to change user home to be a shared folder:
e.g.
-vmargs
-Duser.home=C:\Development
Launch Eclipse. Should see ".eclipse", ".tooling", etc folders created in shared folder, and nothing created under your user folder.
As of Eclipse Java 2019-06 for Windows 10 64-bit
I added my eclipse.ini below:
-vmargs
-D"user.home=C:\your_path_here"
The 3 folders of .eclipse, .p2, & .tooling appeared after I started and then closed eclipse.
I am not sure when these are written into the new path, but it worked in my Windows 10.
Did you try adding the following line to eclipse.ini below -vmargs:
-Dosgi.configuration.area=#user.home/.someFolder
which will use .someFolder instead of .eclipse
or
-Dosgi.configuration.area=C:\path_to_desired_location\.eclipseJAVA

Eclipse opens blank workspace

I have this weird issue where the following happens:
fresh eclipse juno install (with all updates applied)
works fine for a while asking which workspace I want to open with a dialog on startup
after a few days it stops prompting me for workspace, opens blank made up workspace instead in /Users/myself/Documents
If I check "preferences -> workspace -> startup and shutdown" everything seems fine, the only workspace in the list is the one I created and the checkbox that says "don't prompt for workspace" is not checked.
This happened a few times already on fresh eclipse installations and fresh hard drives (same machine but I replaced the hard drive, re-installed OS and everything for other reasons and now it happened again).
I am on:
OSX 10.7.5
Eclipse Juno (Service release 2)
Any help appreciated!
I have exactly the same problem on OSX, for no reason, one fine day, Eclipse will start-up with a new blank workspace!
And to all the stupid answers and responders out there: YES I know how to set and select a default workspace! And NO creating a new workspace, re-importing lots of projects and loosing all my 30+ database connections under my Toad Extension, is not an option.
What I found is that
For some reason Eclipse creates a directory /Users/user_name/Documents/workspace which is the blank workspace it starts-up with (incorrectly)
My usual workspace is under /Users/user_name/Documents/Development/eclipse
The solution is (this is on Mac OSX, don't know if it is the same on Windows):
Goto your Eclipse directory where you run Eclipse from (mine is /Applications/eclipse)
In {eclipse_dir}/configuration open the file config.ini
Find the line osgi.instance.area.default=#user.home/... and confirm that it is pointing to the bogus workspace directory.
Modify the path of this entry to point to the correct workspace
Save the config.ini file.
Try starting Eclipse and it should open your workspace now.
If your Eclipse get stuck loading plugins now, goto your workspace directory and look for the .metadata directory (its hidden). Inside the .metadata directory, remove the .mylyn directory and restart Eclipse.
Once Eclipse started with the correct workspace loaded, do a proper Eclipse shutdown to ensure your workspace is closed and saved properly.
This worked for Eclipse Juno.
Hope this helps!
Just running this command helped me
eclipse.exe -data C:\Development\Eclipse\Workspace
FYI this happens due to install of some plugins.
This same problem happened to me on Windows on two separate Eclipse installations, without installing any plugin.
I was able to get my working Workspace by clicking on File > Switch Workspace, but closing and opening Eclipse again would reset it to a default Workspace.
What apparently solved this was to force Eclipse to save Workspace settings by ticking the Prompt for workspace on startup setting in General > Startup and Shutdown > Workspaces, which I had turned off.
The next time Eclipse opened, it asked me for the Workspace, and it had my correct one first in the list. I asked not to be prompted again for it and now it opens the right workspace when I launch Eclipse once again.
I solved this problem as per JJ-za's answer, except steps 2 and 3:
In {eclipse_dir}/configuration/.settings open the file org.eclipse.ui.ide.prefs (when Eclipse is not running)
Find the line RECENT_WORKSPACES= and confirm that the workspace is pointing to the correct workspace directory and that multiple workspaces are separated by \n

Where does eclipse store information about open perspectives etc?

After a recent upgrade to eclipse Juno, I have a problem with eclipse no longer being able to remember certain settings across restarts and workspace switches. Things like which perspectives were open, certain settings like "[x] Open Dashboard" (spring ide) seem to revert to their factory settings whenever eclipse is restarted.
I use Ubuntu and for historical reasons I maintain my eclipse installation in /opt/eclipse. The installation is owned by root, and apart from some issues with upgrades, this has not actually been a problem - until the Juno release.
I have tried chown -R myself:myself on the eclipse installation directory, and I have verified that all files are indeed editable by my own user. Still, the perspectives seem to reset.
Is there any other place where eclipse stores this information, which might still be owned by root?
Information about perspectives is stored in < workspace>\.metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi
Keep this file backed up if you use complicated customized perspectives.
P.S. It's also useful to know that deleting this file may solve the problem when Eclipse doesn't start (see also here)
That information is kept in the .metadata directory in each workspace root directory.
Two solutions:
MENU -> File -> Switch workspace -> Other -> Copy Settings of
Workbench Layout
Working Sets
Copy/backup and replace following folder to new created Workspace.
[workspace]/.metadata/.plugins/org.eclipse.ui.workbench/
[workspace]/.metadata/.plugins/org.eclipse.core.runtime/.settings/
Personally I prefer (2).
The above answer is credited to #Ischin, in the following reference...

Enterprise Configuration of Workspace mechanic

I am using Google's Workspace Mechanic to configure my eclipse environment. All seems to work fine, except that for any fresh installation, the workspace mechanic opens up with a default location of its own (~/.eclipse/mechanic) to look for preference files.
As given in their documentation i tried including their code
(/instance/com.google.eclipse.mechanic/mechanicSourceDirectories=/shared/eclipse/tasks\:${user_homedir}/.eclipse/mechanic)
in my plugin_customization.ini , but it does not work for me.
Does anyone have any other idea as to how to achieve this?
Quite late, but I just needed the same configuration.
First locate your plugin_customization.ini (eg. 'find -name plugin_customization.ini' in your eclipse folder).
I had two files with same name, located in org.eclipse.platform and org.eclipse.epp.package.jee.
For me, the jee one was relevant and you can configure it as JSON Array.
com.google.eclipse.mechanic/mechanicSourceDirectories=["http\://server/mechanics/tasks.json","/tmp"]
This example shows how to configure a folder (/tmp) and via http location.
Under Windows, I found that when using the recent Eclipse Juno and the latest Workspace Mechanic I had to do the following:
Edit the (Java EE):
...\Eclipse_Juno_SR1\plugins\org.eclipse.epp.package.jee_1.5.1.20120828-0743\plugin_customization.ini
and add the following line at the end:
com.google.eclipse.mechanic/mechanicSourceDirectories=c:\\...\\eclipse_extensions\\WorkspaceMechanics
in order for the plugin to recognize the above directory as the shared folder...
The plugin preferences now correctly references the folder !
The documentation is for Eclipse on Linux/Unix. If you are running Eclipse on Windows you will need a different path.
Another aproch is to put the preferencces in another file and point to that file from your eclipse.ini with a line such as
-Declipse.pluginCustomization=/var/wsm/current/my.properties
or eclipse startup with
eclipse -pluginCustomization /var/wsm/current/my.properties
The following worked for me (for Eclipse Luna in Windows).
Open the Luna/plugins folder
Search for a folder that begins with org.eclipse.epp.package.
(and I ended up with org.eclipse.epp.package.java_4.4.1.20140925-1820)
Go inside that folder and edit plugin_customization.ini
Append the following at the end (to point to \\sharedserver\share\DEV\Workspace-Prefs-Luna):
#Workspace Mechanic Settings
com.google.eclipse.mechanic/mechanicSourceDirectories=\\\\\sharedserver\\share\\DEV\\Workspace-Prefs-Luna
Save and Close the file
Restart Eclipse

Eclipse autosave workspace

Is there a plugin for Eclipse which would automatically save the eclipse workspace every say 5 minutes in the background because every time eclipse crashes the entire workspace layout reverts or open files gets lost, and it is quite annoying at this point.
Windows -> Preferences -> General -> Workspace
There is a box for the "Workspace save interval". But I am not sure that this is the thing you're looking for.
Yes, there is a plugin "Smart Save".
To save the layout, just change everything the way you like and then restart. Eclipse won't corrupt its prefs after a crash, so this should work. As an additional step, you can save the current perspective under a different name and export the prefs to a file. You can then load this file in case of a disaster.
I don't have a solution for the lost files issue, though.
This Eclipse bug entry references the saveuistate plugin which is supposed to autosave the workspace state if changed every 5 minutes or after every build. Note: the aforementioned bug entry states that you must alter the plugin's MANIFEST.MF file to bump the supported Eclipse version numbers...
I haven't tried it yet but it sounds like this is exactly what the OP wanted.
I'll be trying it soon because I have the same issue -- when my VirtualBox Ubuntu guest environment crashes (it does happen...) I have to re-open my previously open files/tabs... sigh...