在 Mac 上打开多个 Eclipse 工作区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/118243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open multiple Eclipse workspaces on the Mac
提问by Thilo
How can I open multiple Eclipse workspaces at the same time on the Mac?
如何在 Mac 上同时打开多个 Eclipse 工作区?
On other platforms, I can just launch extra Eclipse instances, but the Mac will not let me open the same application twice. Is there a better way than keeping two copies of Eclipse?
在其他平台上,我可以只启动额外的 Eclipse 实例,但 Mac 不允许我打开同一个应用程序两次。有没有比保留两个 Eclipse 副本更好的方法?
采纳答案by Tim Visher
EDIT:Milhous's answerseems to be the officially supported way to do this as of 10.5. Earlier version of OS X and even 10.5 and up should still work using the following instructions though.
编辑:Milhous 的答案似乎是从 10.5 开始官方支持的方法。较早版本的 OS X 甚至 10.5 及更高版本仍应使用以下说明工作。
Open the command line(Terminal)
Navigate to your Eclipse installation folder, for instance:
cd /Applications/eclipse/
cd /Developer/Eclipse/Eclipse.app/Contents/MacOS/eclipse
cd /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
cd /Users/<usernamehere>/eclipse/jee-neon/Eclipse.app/Contents/MacOS
Launch Eclipse:
./eclipse &
打开命令行(终端)
导航到您的 Eclipse 安装文件夹,例如:
cd /Applications/eclipse/
cd /Developer/Eclipse/Eclipse.app/Contents/MacOS/eclipse
cd /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
cd /Users/<usernamehere>/eclipse/jee-neon/Eclipse.app/Contents/MacOS
启动 Eclipse:
./eclipse &
This last command will launch eclipse and immediately background the process.
最后一条命令将启动 eclipse 并立即将进程后台运行。
Rinse and repeat to open as many unique instances of Eclipse as you want.
冲洗并重复以根据需要打开尽可能多的独特 Eclipse 实例。
Warning
警告
You might have to change the Tomcatserver ports in order to run your project in different/multiple Tomcat instances, see Tomcat Server Error - Port 8080 already in use
您可能必须更改 Tomcat服务器端口才能在不同/多个 Tomcat 实例中运行您的项目,请参阅Tomcat 服务器错误 - 端口 8080 已在使用中
回答by Milhous
This seems to be the supported native method in OS X:
这似乎是 OS X 中支持的本机方法:
cd /Applications/eclipse/
open -n Eclipse.app
Be sure to specify the ".app" version (directory); in OS X Mountain Lion erroneously using the symbolic link such as open -n eclipse
, might get one GateKeeper stopping access:
请务必指定“.app”版本(目录);在 OS X Mountain Lion 中错误地使用符号链接,例如open -n eclipse
,可能会导致 GateKeeper 停止访问:
"eclipse" can't be opened because it is from an unidentified developer.
Your security preferences allow installation of only apps from the Mac App Store and identified developers.
无法打开“eclipse”,因为它来自身份不明的开发人员。
您的安全首选项只允许安装来自 Mac App Store 和已确定的开发人员的应用程序。
Even removing the extended attribute com.apple.quarantine
does not fix that. Instead, simply using the ".app" version will rely on your previous consent, or prompt you once:
即使删除扩展属性com.apple.quarantine
也不能解决这个问题。相反,简单地使用“.app”版本将依赖于您之前的同意,或者提示您一次:
"Eclipse" is an application downloaded from the Internet. Are you sure you want to open it?
“Eclipse”是从互联网下载的应用程序。您确定要打开它吗?
回答by col.panic
By far the best solution is the OSX Eclipse Launcher presented in http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.htmlIt can be downloaded in the Marketplace http://marketplace.eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
到目前为止,最好的解决方案是http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.html 中提供的 OSX Eclipse Launcher可以在市场http://marketplace 中下载。 eclipse.org/content/osx-eclipse-launcher#.UGWfRRjCaHk
I use it everyday and like it very much! To demonstrate the simplicity of usage just take a look at the following image:
我每天都在使用它,非常喜欢它!为了演示使用的简单性,请看下图:
回答by A. K. Sahu
To make this you need to navigate to the Eclipse.app directory and use the following command:
为此,您需要导航到 Eclipse.app 目录并使用以下命令:
open -n Eclipse.app
回答by Jevgeni Kabanov
Actually a much better (GUI) solution is to copy the Eclipse.app to e.g. Eclipse2.app and you'll have two Eclipse icons in Dock as well as Eclipse2 in Spotlight. Repeat as necessary.
实际上,更好的(GUI)解决方案是将 Eclipse.app 复制到例如 Eclipse2.app,这样您将在 Dock 中拥有两个 Eclipse 图标以及在 Spotlight 中拥有 Eclipse2。根据需要重复。
回答by aaron
If the question is how to easily use Eclipse with multiple differentworkspaces, then you have to use a kludge because shortcuts in OS X do not provide a mechanism for passing command line arguments, for example the "--data" argument that Eclipse takes to specify the workspace. While there may be different reasons to create a duplicate copy of your Eclipse install, doing it for this purpose is, IMNSHO, lame (now you have to maintain multiple eclipse configurations, plugins, etc?).
如果问题是如何轻松地将 Eclipse 与多个不同的工作区一起使用,那么您必须使用 kludge,因为 OS X 中的快捷方式不提供传递命令行参数的机制,例如 Eclipse 使用的“--data”参数指定工作区。虽然可能有不同的原因来创建 Eclipse 安装的重复副本,但为此目的这样做是,IMNSHO,跛脚(现在您必须维护多个 Eclipse 配置、插件等?)。
In any case, here is a workaround. Create the following script in the (single) Eclipse directory (the directory that contains Eclipse.app), and give it a ".command" suffix (e.g. eclipse-workspace2.command) so that you can create an alias from it:
无论如何,这里有一个解决方法。在(单个)Eclipse 目录(包含 Eclipse.app 的目录)中创建以下脚本,并为其添加“.command”后缀(例如 eclipse-workspace2.command),以便您可以从中创建别名:
#!/bin/sh
# open, as suggested by Milhous
open -n $(dirname ##代码##)/Eclipse.app --args -data /path/to/your/other/workspace
Now create an alias to that file on your desktop or wherever you want it. You will probably have to repeat this process for each different workspace, but at least it will use the same Eclipse installation.
现在在您的桌面上或您想要的任何地方为该文件创建一个别名。您可能需要为每个不同的工作区重复这个过程,但至少它会使用相同的 Eclipse 安装。
回答by Fangming
2018 Update since many answers are no longer valid
2018 更新,因为许多答案不再有效
OS X Heigh Sierra (10.13) with Eclipse Oxygen
带有 Eclipse Oxygen 的 OS X Heigh Sierra (10.13)
Go to wherever your Eclipse is installed. Right-click -> Show Package Contents -> Contents -> MacOS -> Double-click the executable called eclipse
转到安装了 Eclipse 的任何位置。右击 -> Show Package Contents -> Contents -> MacOS -> 双击名为 eclipse 的可执行文件
A terminal window will open and a new instance of eclipse will start.
将打开一个终端窗口并启动一个新的 eclipse 实例。
Note that if you close the terminal window, the new Eclipse instance will be closed also.
请注意,如果您关闭终端窗口,新的 Eclipse 实例也将关闭。
To make your life easier, you can drag the executable to your dock for easy access
为了让您的生活更轻松,您可以将可执行文件拖到 Dock 中以方便访问
回答by Sujan Reddy A
One another way is just to duplicate only the "Eclipse.app" file instead of making multiple copies of entire eclipse directory. Right-Click on the "Eclipse.app" file and click the duplicate option to create a duplicate.
另一种方法是仅复制“Eclipse.app”文件,而不是制作整个 eclipse 目录的多个副本。右键单击“Eclipse.app”文件,然后单击复制选项以创建副本。
回答by Pete
Instead of copying Eclipse.app around, create an automator that runs the shell script above.
不要复制 Eclipse.app,而是创建一个运行上面的 shell 脚本的自动程序。
Run automator, create Application.
运行 automator,创建应用程序。
choose Utilities->Run shell script, and add in the above script (need full path to eclipse)
选择Utilities->Run shell script,加入上面的脚本(需要eclipse的完整路径)
Then you can drag this to your Dock as a normal app.
然后您可以将其作为普通应用程序拖到 Dock 中。
Repeat for other workspaces.
对其他工作区重复此操作。
You can even simply change the icon - https://discussions.apple.com/message/699288?messageID=699288