How to launch eclipse from a command line on MacOS with a workspace pathname
On linux:
开发者_运维技巧eclipse PathnameToWorkspace
works fine, and launches eclipse on the workspace.
I've never been able to figure out the MacOS moral equivalent, given the MacOS application tree structure.
I suspect this is not a hard problem.
./eclipse -data <workspace-path>
(see also How do I run Eclipse in the Eclipse Wiki).
On my system there's a link to the eclipse binary from /Applications/eclipse/eclipse
, and I find that just running that will start Eclipse with my default workspace.
You might also find the Eclipse binary in '/Applications/Eclipse.app/Contents/MacOS/eclipse'.
When I start Eclipse like this (from the command line) I find that my Mac will not always switch to the desktop where Eclipse is started, so that I will have to go hunt for the Eclipse window with Exposé/Misson Control (Ctrl-Up Arrow). – This is especially true when I'm have two monitors connected to my Mac.
Since I found typing the full path to eclipse annoying, I simply added a symlink to it from /opt/local/bin
and made sure that directory is in my $PATH
:
cd /opt/local/bin
sudo ln -s /Applications/eclipse/eclipse .
echo 'PATH="$PATH:/opt/local/bin' >>~/.bashrc
After that, just issuing the command eclipse
(without the preceding /Applications/eclipse
part) works as it should.
On my Mac running High Sierra the Eclipse Binary was located in /Users/<username>/eclipse/<tool-chain-version>/Eclipse.app/Contents/MacOS/
Where the tool-chain-version is the specific version of Eclipse that was installed, in my case it was javascript-2018-12. I believe they follow this pattern, for example j2ee-2019-01.
Running the eclipse binary in that directory starts eclipse from the command line.
After doing lots of hit and try I have added following into my bash_profile and I am able to launch eclipse from terminal.
(Note: Eclipse is inside Application)
export PATH="$PATH:/Applications/Eclipse.app/Contents/MacOS"
Hope it will be helpful for beginner like me.
精彩评论