Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Eclipse use a native launcher?

Eclipse the IDE is one of the best examples of a huge desktop application written in Java.

Most Java applications I've seen usually rely on a batch or shell script to build a string with the class path of the application, and launch the JVM with the class path as an env variable.

Eclipse, on the other hand, relies on a native launcher. Why is that ? What does this launcher do that scripts don't ?

I remember reading an article about a year and a half ago that explained that "we're better off with a native launcher", but id did not explain the inner workings of the launcher.

like image 381
Leonel Avatar asked Jan 26 '09 11:01

Leonel


People also ask

What is Eclipse launcher?

PDE provides an Eclipse Application launcher which allows you to run and debug your plug-in by launching a separate Eclipse application.


1 Answers

The Equinox launcher uses JNI to start the Java VM in the same process as the launcher. Using JNI also allows us to use SWT widgets in the splash screen.


Actually, you can still have a script, since the launcher executable, eclipse.exe, has been broken into 2 pieces since 3.3M5:

  • the executable, and
  • a shared library (eg: eclipse_1006.dll).

The executable lives in the root of the eclipse install.
The shared library is in a platform specific fragment, org.eclise.equinox.launcher.[config], in the plugins directory.

Moving the majority of the launcher code into a shared library that lives in a fragment means that that portion of the launch code can now be updated from an update site. Also, when starting from java, the shared library can be loaded via JNI in order to display the splash screen.

As explained here, you can start Eclipse 3.3 without the native launcher,

java -jar plugins/org.eclipse.equinox.launcher_1.0.0.v20070319.jar

Note that the name of the jar-file is now version dependent causing naive scripts, that invoke the jar using the exact filename, to break once the jar-file gets updated.

Instead you may want to look for a file matching org.eclipse.equinox_*.jar. Thankfully the Eclipse-wiki contains appropriate scripting templates that are useful in this case.
If you want to avoid modifying existing scripts, you can also search for the Equinox Launcher plug-in, copy it into the Eclipse main directory and rename the copy into startup.jar.

like image 56
VonC Avatar answered Sep 21 '22 02:09

VonC