开发者

How to tell Eclipse Workspace?

开发者 https://www.devze.com 2023-01-28 03:54 出处:网络
I开发者_如何学运维s there a way to tell what is the current Eclipse workspace you are currently working on?For me it work to choose File->Switch Workspace->Other... and it shows the name of current wo

I开发者_如何学运维s there a way to tell what is the current Eclipse workspace you are currently working on?


For me it work to choose File->Switch Workspace->Other... and it shows the name of current workspace.


I tried to confirm

"Actually, this shows the last workspace that was closed, not the current workspace. If you are opening and closing several, this is not dependable."

and I am not able to reproduce it. Each time I get the currently loaded workspace (I was testing on Juno). I also checked sources and in ChooseWorkspaceDialog.java and ChooseWorkspaceData.java, and it looks like it manages simple list of last time opened workspaces which is stored as a RECENT_WORKSPACES key in org.eclipse.ui.ide.prefs file. The workspace name shown in this dialog is the first one from this list.


start eclipse with -showlocation

Here are two interesting posts about it:

top-10-tips-for-new-eclipse-users (archived version)

eclipse-startup-options-showlocation


Go Window>Preferences. Then under General>Workspace there is a property: "Workspace name (shown in window title)" and put in some sort of identifying label.

You'll need to set this up for each workspace you have, but it's an easy way to know which workspace you're in at a glance.


Eclipse Neon (4.6)

According to M7, workspace name is shown in window title by default.

Eclipse Mars (4.5)

Window > Preferences > General > Workspace

How to tell Eclipse Workspace?

How to tell Eclipse Workspace?

There is also a check box "Show workspace path in window title".
The result looks like this:

How to tell Eclipse Workspace?

This feature is described here.


If any project exists in the workspace:

Select a project and its properties (e.g. Menu: Project -> Properties or right mouse button->Properties). Then go to Resource -> Linked Resources and the WORKSPACE_LOC's Path Variable value shows the current workspace path.


There's an environment variable called osgi.instance.area. You can find it via "Help -> About Eclipse -> Installation Details -> Configuration" (for eclipse "Helios" 3.6)

Or, open the properties of any project, then select "Resource". You'll find a "Location" property which is structured like this:

<path-to-current-workspace>/<name-of-current-project>

Note - the "erased" procedure works in most cases but can not be used in general, because a project folder does not have to be located in the workspace folder. You can choose external locations during project creation. So if you never uncheck the "Use default location", the procedure is save. The first procedure is reliable.


File->Properties

Select a file in the workspace and then use the menu: "File->Properties". A dialog pops up and should show the 'location' of the file. Read the location from right to left so you go through the class, package, folder, project, then you should see the workspace.


Summary:
(from most immediate to lesser (but more elegant), leaving out redundant ones)

  1. File > Switch
    File->Switch Workspace->Other... -> full answer
  2. Help > About
    Help -> About Eclipse -> Installation Details -> Configuration: osgi.instance.area ->full answer
  3. Title bar (start-up parameter)
    If you start eclipse with -showlocation -> full answer
  4. Title bar (naming workspaces)
    Give each workspace a name -> full answer


Check the path of any resource in the resource's properties. Then you'll know. OR: Go to Preferences > General > Workspace and add a Workspace name (shown in window title)


Use the switch workspace from the file menu and you will know it


start eclipse with -data

example: c:\eclipse\eclipse.exe -data c:\workspaces\myWorkspace1


-showlocation is great, but it only changes the text at the end of the title bar, so it's often not visible in the taskbar.

If you want to change the beginning of the title bar, which shows the current Perspective, you can use Window -> Save Perspective As... and the new title will be visible in the Taskbar.


  1. Go to File->Switch Workspace.
  2. You can see a list of workspaces excluding your current workspace.
  3. Now go to the physical location and see which one is missing in the list.

The missing one is your current workspace.


http://mcuoneclipse.com/2012/08/01/show-workspace-location-in-the-title-bar/

http://www.rekk.de/bloggy/2007/eclipse-show-workspace-location-in-title-bar/

add -showlocation to your shortcut.

c:\eclipse\eclipse.exe -showlocation


I just found my current Workspace with Simplest Way.

Step 1:

Start Your Eclipse (If default workspace is set, Eclipse never ask for Choose workspace OR it will set to path which we have used last time)

Step 2:

When Eclipse start Completely, try to Start Eclipse again with same shortcut/exe file. It will show you below error message and you will get your default/current workspace

How to tell Eclipse Workspace?


File -> Switch Workspace


If you want to switch wokspace, then File->Switch Workspace. Click "Other" and choose appropriate folder. Is that what you want? :)


I created an External Tool Launch Configuration containing the following (exported echo-workspace.launch file content):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration
    type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
    <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
        <listEntry value="org.eclipse.ui.externaltools.launchGroup" />
    </listAttribute>
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}" />
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="c:\Windows\System32\cmd.exe" />
    <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="/c echo &quot;${workspace_loc}&quot;" />
</launchConfiguration>

So that the workspace folder path is echoed in the console.

Feel free to copy this into a .launch file and import it into Eclipse: File > Import ... > Run/Debug > Launch Configurations

I'll figure out a Mac/UNIX version soon, as I was on Indigo/Win when I made this one.


You will often have to use multiple running Eclipse instances at a time. To switch between them, it's helpful to set a name for the workspace that is displayed in the title of the Eclipse window. To do this, open Window/Preferences. In the Preferences window navigate to General/Workspace and give every workspace an individual workspace name.


I got into a situation which caused eclipse startup to fail completely due to workspace corruption.

(Similar to Eclipse won't start, log error says: ObjectNotFoundException: Tree element)

It had been so long since i used eclipse that i forgot where my workspace was. This is where i found the setting.

~$ grep osgi.instance.area.default eclipse/configuration/config.ini osgi.instance.area.default=@user.home/Documents/workspace


If you want to find the path programatically, use this:

ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();


Simple Logic...

Just Click on File menu then Switch Work Place

Click on Other

Then the dialogue pops up with current workspace highlighted on the top of the list. If you click on this list, other workplaces are shown.


clicking File->Switch Workspace gives the wrong result on my system.
This method gives the correct result:
File -> Properties -> Resource
now check the path in the third line labeled "location" in window labeled Resource
It will show the workspace folder just before the project folder.


windnow -> preference -> General -> startup and shutdown -> workspaces - top one will be your current workspace.


  1. Go to Window -> Preferences.
  2. Search for Workspaces & select.
  3. The top one is your current workspace.
0

精彩评论

暂无评论...
验证码 换一张
取 消