## Sunday, April 15, 2012

### Equinox Framework

Equinox
The Equinox Framework component is tasked with being a full implementation to the OSGi Core Framework R4 specification. In addition, the Framework component produces launchers, bootstrap infrastructure and application models that facilitate the use of Equinox OSGi in end-user product scenarios.

### Framework Projects

 OSGi R4 Framework (org.eclipse.osgi)The main framework project. This includes a set of adaptors and enough function to make a standalone OSGi framework. When built this project produces org.eclispe.osgi.jar. Java Launcher (org.eclipse.equinox.launcher)This helps setup the framework classloader and launches the Framework etc. Note: this code used to be included in the startup.jar and has be moved from its old location in the org.eclipse.platform project. See bug 113069 for more details. Native Launcher (org.eclipse.equinox.executable)The launcher is the native executable that finds and runs the java launcher org.eclipse.equinox.launcher and thus the framework. It is also responsible for putting up the splash screen etc. The launcher is written in C and currently supports a wide range of operating systems, window systems and processor architectures. The launcher is split into a small native executable and a platform specific library. The source for both the launcher and the library can be found in the org.eclipse.equinox.executable project.

Equinox_Launcher@Wiki

You can start Eclipse by running eclipse.exe on Windows or eclipse on other platforms. This small launcher essentially finds and loads the JVM. On Windows, the eclipsec.exe console executable can be used for improved command line behavior.
Alternatively, you can launch Eclipse by directly invoking the JVM as follows:
   java -jar eclipse/plugins/org.eclipse.equinox.launcher_1.0.0.v20070606.jar


## Find the JVM

If a JVM is installed in the eclipse/jre directory, Eclipse will use it; otherwise the launcher will consult the eclipse.ini file and the system path variable. Eclipse DOES NOT consult the JAVA_HOMEenvironment variable.
To explicitly specify a JVM of your choice, you can use the -vm command line argument:
   eclipse -vm c:\jre\bin\javaw.exe              ''start Java by executing the specified java executable
eclipse -vm c:\jre\bin\client\jvm.dll         ''start Java by loading the jvm in the eclipse process

See the launcher page for more details on specifying a JVM.

# Starting Eclipse Commandline With Equinox Launcher

### Ant Script

<!-- set path to eclipse folder. If local folder, use '.'; otherwise, use c:\path\to\eclipse or /path/to/eclipse/ -->
<property name="eclipse.home" value="."/>

<nowiki><!--  get path to equinox jar inside ${eclipse.home} folder (copy/rename actual jar) --></nowiki> <copy tofile="''${eclipse.home}''/eclipse/plugins/org.eclipse.equinox.launcher.jar">
<fileset dir="''${eclipse.home}''/eclipse/plugins" includes="**/org.eclipse.equinox.launcher_*.jar"/> </copy> <nowiki><!-- start Eclipse w/ java --></nowiki> <java classpath="''${eclipse.home}''/eclipse/plugins/org.eclipse.equinox.launcher.jar"
.../>
Or, if you are using Ant 1.7 and don't like copying resources around (or don't have permission to do so) this appears to work to set the path to the newest available equinox launcher jar in a property for later use:
<!-- set path to eclipse folder. If local folder, use '.'; otherwise, use c:\path\to\eclipse or /path/to/eclipse/ -->
<property name="eclipse.home" value="."/>

<!-- store path to newest launcher JAR in path id 'newest.equinox.launcher.path.id' -->
<first count="1">
<sort>
<fileset dir="${eclipse.home}/eclipse/plugins" includes="**/org.eclipse.equinox.launcher_*.jar"/> <nowiki><!-- Seems the default order is oldest > newest so we must reverse it. The 'reverse' and 'date' comparators are in the internal antlib org.apache.tools.ant.types.resources.comparators. --></nowiki> <reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators"> <nowiki><!-- 'date' inherits 'reverse's namespace --></nowiki> <date/> </reverse> </sort> </first> </path> <!-- turn the path into a property --> <property name="equinox.launcher.jar.location" refid="newest.equinox.launcher.path.id" /> <!-- you can now reference the jar through the property${equinox.launcher.jar.location} -->
<echo message="Using equinox launcher jar: ${equinox.launcher.jar.location}" /> ### Bash Shell Script  #!/bin/bash # set path to eclipse folder. If the same folder as this script, use the default; otherwise, use /path/to/eclipse/ eclipsehome=dirname$BASH_SOURCE;

# get path to equinox jar inside $eclipsehome folder cp=$(find $eclipsehome -name "org.eclipse.equinox.launcher_*.jar" | sort | tail -1); # start Eclipse w/ java /opt/java50/bin/java -cp$cp org.eclipse.equinox.launcher.Main ...


### Cmd/Bat Script

Save this as eclipse.cmd. This has been tested with Windows XP Pro (SP2).
 @echo off

:: set path to eclipse folder. If local folder, use '.'; otherwise, use c:\path\to\eclipse
set ECLIPSEHOME=.

:: get path to equinox jar inside ECLIPSEHOME folder
for /f "delims= tokens=1" %%c in ('dir /B /S /OD %ECLIPSEHOME%\plugins\org.eclipse.equinox.launcher_*.jar') do set EQUINOXJAR=%%c

:: start Eclipse w/ java
echo Using %EQUINOXJAR% to start up Eclipse...
java -jar %EQUINOXJAR% ...