Open multiple Eclipse workspaces on the Mac - eclipse

How can I open multiple Eclipse workspaces at the same time on the Mac?
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?

This seems to be the supported native method in 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:
"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.
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:
"Eclipse" is an application downloaded from the Internet. Are you sure you want to open it?

By far the best solution is the OSX Eclipse Launcher presented in http://torkild.resheim.no/2012/08/opening-multiple-eclipse-instances-on.html It can be downloaded in the Marketplace 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:

EDIT: Milhous's answer seems 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.
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 &
This last command will launch eclipse and immediately background the process.
Rinse and repeat to open as many unique instances of Eclipse as you want.
Warning
You might have to change the Tomcat server ports in order to run your project in different/multiple Tomcat instances, see Tomcat Server Error - Port 8080 already in use

To make this you need to navigate to the Eclipse.app directory and use the following command:
open -n Eclipse.app

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.

If the question is how to easily use Eclipse with multiple different workspaces, 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?).
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:
#!/bin/sh
# open, as suggested by Milhous
open -n $(dirname $0)/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.

2018 Update since many answers are no longer valid
OS X Heigh Sierra (10.13) with Eclipse Oxygen
Go to wherever your Eclipse is installed. Right-click -> Show Package Contents -> Contents -> MacOS -> Double-click the executable called eclipse
A terminal window will open and a new instance of eclipse will start.
Note that if you close the terminal window, the new Eclipse instance will be closed also.
To make your life easier, you can drag the executable to your dock for easy access

Instead of copying Eclipse.app around, create an automator that runs the shell script above.
Run automator, create Application.
choose Utilities->Run shell script, and add in the above script (need full path to eclipse)
Then you can drag this to your Dock as a normal app.
Repeat for other workspaces.
You can even simply change the icon - https://discussions.apple.com/message/699288?messageID=699288&#699288

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.

If you're like me, you probably have terminal running most of the time as well.
You could just create an alias in /Users//.bash_profile like this
alias eclipse='open -n path_to_eclipse.app'
then all you have to do is just open the terminal and type eclipse.

Based on a previous answer that helped me, but different directory:
cd /Applications/Eclipse.app/Contents/MacOS
./eclipse &
Thanks

You can create an AppleScript file to open Eclipse with a given workspace. You can even save the AppleScript file as an Application, which is equivalent to creating an alias with arguments in Windows OS.
Open Script Editor and type the following:
do shell script "open '/path/to/your/Eclipse/installation' -n --args -data /path/to/your/workspace"
For instance:
do shell script "open '/Applications/Eclipse.app' -n --args -data /MyWorkspaces/Personal"
Press the Run button to check it's working.
This script can be saved as such, but I prefer to save it as an Application. That way I can customize the icon by copying the *.icns icon from the original Eclipse.app bundle to the script application bundle.
To open an App folder, use the "see contents" contextual menu option. It should look like this:
Where "main.scpt" is the AppleScript file and "applet.icns" is the icon from the original Eclipse bundle.

Launch terminal and run open -n /Applications/Eclipse.app for a new instance.

I found this solution a while back, can't remember where but it still seems to work well for me.
Create a copy of Eclipse.app for each workspace you want to work in (for this example ProjectB.app), then open ProjectB.app/Contents/MacOS/eclipse.ini and add these two lines at the beginning of the file:
-data
/Users/eric/Workspaces/projectb
... substituting where your workspace is located. When you launch ProjectB.app it will automatically start with that workspace instead of prompting for a location, and you should be able to run it at the same time as other Eclipse instances with no problem.

In Terminal simply paste below line and hit enter ..
/Applications/Eclipse.app/Contents/MacOS/eclipse ; exit;

If you want to open multiple workspaces and you are not a terminal guy, just locate the Unix executable file in your eclipse folder and click it.
The path to the said file is
Eclipse(folder) -> eclipse(right click) -> Show package
Contents -> Contents -> MacOs -> eclipse(unix executable file)
Clicking on this executable will open a separate instance of eclipse.

A more convenient way:
Create an executable script as mentioned above:
#!/bin/sh
cd /Applications/Adobe\ Flash\ Builder\ 4.6
open -n Adobe\ Flash\ Builder\ 4.6.app
In you current instance of Flashbuilder or Eclipse, add a new external tool configuration. This is the button next to the debug/run/profile buttons on your toolbar. In that dialog, click on "Program" and add a new one. Give it the name you want and in the "Location" field, put the path to the script from step 1:
/Users/username/bin/flashbuilder
You can stop at step 2, but I prefer adding a custom icon to the toolbar. I use a the Quick Launch plugin to do that:
http://sourceforge.net/projects/quicklaunch/files/
After adding the plugin, go to "Run"->"Organize Quick Lauches" and add the external tool config from step 2. Then you can configure the icon for it.
After you save that, you'll see the icon in your toolbar. Now you can just click it every time you want a new Flashbuilder/Eclipse instance.

You can run multiple instances of Eclipse by creating a pseudonym for Eclipse application in it's folder and using it for running new Eclipse instance

Lets try downloading this in your eclipse on Mac you will be able to open multiple eclipse at a time Link
Name : macOS Eclipse Launcher
Steps :
Go to eclipse Market place.
Search for "macOS Eclipse Launcher" and install.
It will restart .
Now under file menu check for open option > there you will find other projects to open also at same time .

Window -> New Window
This opens a new window and you can then open another project in it. You can use this as a workaround hopefully.
It actually allows you to work in same workspace.

Related

How to change folder that opened by default in VSCode?

I have small problem with VSCode folder, that opened by default.
Problem description: I start new instance of VSCode (trough File->New Window), and then if I choose File->Open Folder it opens dialog with my Windows user folder as starting point (C:\Users\MyUser)
Question: How can I change that folder in settings (if it possible)? So by default it will show as start point for example D:\development\ ?
At the time I write this answer, this is not possible. There are two problems on Windows, and one problem on Mac and Linux:
VS Code does not provide a default path to the file dialog 1. It does remember the last folder that you opened a file in, but that path cannot be used as a default because it is overwritten constantly.
On Windows only, Electron ignores the default path when creating a file dialog if the default path is a directory 2.
An extension also cannot solve this, because extensions are not allowed to modify the File menu 3.
I think the best option at this point is to pin a folder to the Quick Access area in Windows Explorer, as suggested in a comment, or to put an actual shortcut in the user profile folder.
Workspaces and File > Open Recent may also be helpful if you often open the same folders.
Your main problem is that you are unable to open your specific folder in VScode.
To solve that you can simply open the terminal/cmd in that specific window by just typing cmd in your search bar or just by pressing shift+right-click in that folder.
Now your cmd is open and you just have to type "code ." in the cmd and press enter to open the current folder in your VSCode.
In case that code . doesn't work for you then you have to add the Vscode in the environment variables of your windows.
Visual Studio doesn't provide a specific feature to open a specific path. But there is a solution to your problem. You are saying that you want D:\develpment as a default when you open VS Code. You can go to that specific directory or create shortcut to desktop then click right click on that folder and then click on open with code. If you didnot see open with code then reinstall your VS code and check on open with code when you are reinstalling VS Code.
make a shortcut on the desktop for vscode and then modify it and add the folder after the .exe command. This will default open that folder when you double click on it.
Visual Studio Code can be installed in two ways - User setup and System setup. I strongly believe you have User setup installed in your PC. Try re-installing it System-wide. That should probably fix your problem.
For more information: https://code.visualstudio.com/docs/setup/windows#_user-setup-versus-system-setup
PS: A lot more information is needed, you can share a screenshot of the window and elaborate more on it.

Install VSCode in a specific folder

I just downloaded the Visual Studio Code App from https://code.visualstudio.com/ and when I tried to install it, it simply just installed it by itself, without the option to change the installation path.
I have an external harddrive, which is where I want the IDE to be placed instead of the Local Harddrive. How can I change this?
On the VSCode download page select "System Installer" instead of "User Installer". The System installer will prompt you for the install location.
Full credit to Hans Passant for giving the following working solution as a comment.
The installer does very little beyond copying the files, it just creates some Explorer context menu shortcuts ("Open with Code"). Otherwise following Chromium conventions and copying itself to c:\Users\yourname\AppData\Local\Code\app-0.1.0 so it can update itself without you noticing. Boo. So high odds that simply moving that folder to the other drive works just fine, put it anywhere and create a shortcut to Code.exe. If you still want the context menu entry to work then use Regedit and search for "code\app-0.1.0".

Launch terminal from eclipse

I recently switched to Eclipse (Helios) for my programming needs, and I like it very much.
There is just on thing that is driving me crazy, how can I launch (compile and run) my code into the native mac osx terminal.
I tried creating an "external tools configuration", but that just starts the terminal without outputting the application.
What I do now is right-click on the binary in the Project Explorer and then "Open With" and then "Other" and then I pick the terminal app from the list. But this solution is driving me nuts.
Please help.
It's all about defining the External Tool correctly.
For example, the following should work if your selected file is a Unix executable.
Open a new External Tool configuration.
Set the location to /usr/bin/open
Set Working directory as ${selected_resource_loc}
Set the arguments to -a /Applications/Utilities/Terminal.app ${selected_resource_loc}
When you run make sure you select "src"
This should work. You could improve it further. You could even write an AppleScript that would do that and run it using osascript.

Eclipse IDE; Open in current window / instance?

I've been using Eclipse for about a week now and I'm loving it.. great software for the 'price'. :P However, I'm having a few issues getting started.
The most annoying, so far, has been opening files from outside of Eclipse, and having them set to open w/ Eclipse. When I open a file from the file-explorer or an external application (WinSCP for instance), Eclipse seemingly attempts to open an entirely new instance itself rather than opening the file within a currently running instance. Of course, because this is the case, Eclipse errors out w/ 'The workspace is currently in use. Please select another' (or whatever it says).
Is there a configuration option, or an argument that I can use when opening a file externally that will simply use the currently open instance of Eclipse?
Thx in advance! :)
The easiest way to open external file in the current Eclipse is to drag-n-drop it to the tabbed area where your files are displayed. You should consider that Eclipse is seriously geared towards using files as part of a project and opening random file with Eclipse is certainly possible but not encouraged.
To your question - since Eclipse runs in Java if you attempt to use eclipse.exe to open a file then script will always try to open a new instance, I don't know if what you want is actually doable
To add to DroidIn.net's answer, here are a few eclipse bugs related to the question:
bug 4922 (from 2001!): "Need ability to open a file in eclipse from the command line", with sockent-monitoring kind of solutions, like the IBM proposition of opening an RCP from an URL, which leads to plugins like EclipseCalls.
EclipseCall is a plugin that accepts file-open requests on a defined socket port. A specialized client can be used to open a file in Eclipse by command from outside Eclipse, e.g. by double clicking a source file in Windows Explorer.
bug 178927 (2007): "way to pass arguments from launcher to a running application instance", based on a modifier launcher (more Windows-oriented, although bug 201154 is mac-oriented). An OSGi-based solution is also investigated.
(On Linux, see also steb)
In a Mac terminal, you can use open, though I needed to point to the executable explicitly, since I have more than one Eclipse installed:
open -a ~/eclipse/java-oxygen/Eclipse.app --args --launcher.openFile filename
You may or may not need --launcher.openFile, depending if you have --launcher.defaultAction set to openFile in your eclipse.ini file. (This config-file edit is also what you need for double-clicking or "open-with" to use the running Eclipse.)
For instance, I could do this (with gnu parallel) to open all of my failing tests after I'd copied to the clipboard (pbpaste is mac-specific):
pbpaste | parallel find . -name {}\\\* -print \
| parallel open -a ~/eclipse/java-oxygen/Eclipse.app
The Eclipse file-opening documentation for all OSes is here.

Launch mac eclipse with environment variables set

My company provides an eclipse based development environment which needs some environment variables setting up for the underlying toolchain so multiple versions can be installed concurrently and not take over the system.
I want to provide an icon in finder or the dock which sets these then launches eclipse so customers cannot accidentally launch eclipse without the environment being set. This is what I have tried so far:
Setting environment in Info.plist
for eclipse:
This should be a nice way to do it
but I cannot make it add to the
existing path (like export
PATH=/myapp/bin:$PATH).
bash script wrapping eclipse:
I created a bash script called
eclipse.command to set the
environment then launch eclipse.
This opens a terminal window as well
as the eclipse icon and allows
people to "Keep on dock" for the
bare eclipse. I cannot put
eclipse.command on the dock as it is
not an application.
Applescript wrapping eclipse.command:
An Applescript wrapper around
eclipse.command makes it look like
an app and prevents the terminal
window appearing. Unfortunately I
now get a dock icon for the
applescript and one for eclipse so
can still keep the bare eclipse on
the dock.
Any suggestions? Am I going about this in completely the wrong way?
There is an alternate solution which involves replacing the executable that is run by MacOS X when the user launches the Eclipse application with a shell wrapper that sets up the environment.
Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS.
Open the eclipse.sh in a text editor an enter the following contents:
#!/bin/sh
export ENV_VAR1=value
export ENV_VAR2=value
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
In the example ENV_VAR1 and ENV_VAR2 are the environment variables being set up. These variables will be visible to processes launched from within Eclipse. The logger command will just log the path of the eclipse executable to the system.log as a debugging aid.
In the Terminal set the executable flag of the shell script eclipse.sh, i.e.:
chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh
Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.
MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app
The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set.
I created the following:
alias start-eclipse='open /Applications/eclipse/Eclipse.app'
If you run start-eclipse from the command line, all env vars will be picked up. This way, you only need to maintain a single set of env vars across both command-line and eclipse environments.
Take a look at a related question: Environment variables in Mac OS X.
Basically, this involves the creation of a ~/.MacOSX/environment.plist file.
Log out and Log in for the environment.plist to get picked up by .App's
This worked perfectly in OS X Yosemite:
Open /Applications/Automator.
When the drop-down appears asking you what kind of document you want to create, choose "Application."
In the second-from-the-left list, double-click "Run Shell Script."
In the right side delete the "cat" that gets put there automatically, and replace it with this:
source ~/.bash_profile && /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
Now go to File->Save, and save the application to your Applications directory. I named it "Eclipse" with a capital 'E' so as not to conflict with the "eclipse" directory I already had. For good measure, you can even give it the Eclipse icon by selecting the real eclipse app, pressing command-i, selecting the icon, pressing command-c, then selecting the automator "Eclipse" app, pressing command-i, selecting the icon, and pressing command-v.
Now you can open the app, or even drag it to your dock. Note that if you start it, the "real" eclipse will still show up in your dock as a separate icon, but you can't have everything. :)
sakra's answer above is awesome, except is doesn't automatically inherit your existing bash environment. To ensure eclipse.sh picks up your existing bash environment, modify eclipse.sh to use bash instead of sh and add a line to source your existing ~/.bash_profile thus:
#!/bin/bash
source ~/.bash_profile
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
None of the above worked for me. you have to set Eclipse -> Preferences -> Terminal -> Arguments set to --login
That will instruct Eclipse to login with your account just after opening Terminal.
See screenshot:
Reference: https://marketplace.eclipse.org/comment/4259#comment-4259
Link to Eclipse doesn't use the path set in .bashrc
Create simple script
#!/bin/bash
source /home/user/.environment_variables
/home/user/eclipse_cpp/eclipse -Duser.name="My Name"
2.
Next put your all system variables in file /home/user/.environment_variables (any file you want)
My looks like:
export COCOS_ROOT=/home/user/Projects/edukoala
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
3.
Now you can delete your variables in .bashrc and put line
source /home/user/.environment_variables
Everything works fine :)
As pointed out in https://github.com/atom/atom/issues/7045, the environment variables can be loaded automatically, without explicit source ~/.bash_profile by using
#!/usr/bin/env bash -l
instead of
#!/bin/bash
source ~/.bash_profile
after that, in both cases, follows
exec "`dirname \"$0\"`/eclipse" $#
It works great for me, thanks for all previous work.
After setting env variables in .bash_profile.
Simply open the application through terminal!
open /Application/{path/to/app}.app