Skip to main content
Luis de la Rosa

How to run Eclipse from the command line in OS X (and Windows and Linux)

EclipseosxiconThe Mac is very easy to use due to its innovative packaging system for applications, where it hides an entire tree of directories inside one file/icon. With Eclipse, this shows up as the Eclipse icon that we know and love.

However, if you're a hardcore programmer, then you really should get your hands dirty with the command line via OS X's Terminal. This lets you get down to the UNIX core. When you go into your Eclipse install directory, you'll find a nice executable named appropriately enough: "eclipse". Well, it's actually just a symbolic link into the Eclipse.app (the nicely packaged Eclipse application that I mentioned above.)

If you just type "eclipse", you're in for a rude awakening, as you won't be able to interact with the UI and you'll be forced to Control-C. The reason why is due to an obscure implementation of how threading works in the Apple Java Runtime and how it interacts badly with SWT's (and thus Eclipse's) expectation of how it should be running.

The solution, however is simple:

./eclipse -vm Eclipse.app/Contents/MacOS/java_swt

The reason why this works is because of a special version of the Java launcher that accommodates SWT's needs on OS X. You can find out more at the Eclipse Bugzilla, bug 40003.

Here is a nicer version, which lets you see System.out and System.err, as well as Eclipse debug statements, and shows how you can pass in arguments to the underlying VM:

./eclipse -vm Eclipse.app/Contents/MacOS/java_swt -debug -consoleLog -vmargs -Xmx256M

Windows users: You can also run Eclipse from the command line, but you have to make an eclipse.bat file by hand. In this bat(ch) file, include:

eclipse.exe -debug -consoleLog -vmargs -Xmx256M

Linux users: You probably already Eclipse from the command line and you probably don't need my help doing it. ;) But just in case you do, use something like:

./eclipse -debug -consoleLog -vmargs -Xmx256M

Windows and Linux users: You can supply the -vm parameter as well if you want to run Eclipse using another VM, like the JDK 1.5 for example.

You can find out more information about command line arguments to Eclipse in the the Eclipse runtime options page in the Eclipse Help.