Running Eclipse on a machine without Java

As “portable applications” are getting more and more popular, it is important to say that Eclipse has always been portable: just unzip it anywhere and run it. The real issue is not having Java Runtime Environment installed on the machine where you want to run Eclipse. Unfortunately, installing Java on Windows requires full administrator rights.

I decided to create my portable Eclipse distribution on an USB hard drive (a Western Digital Passport) instead of an USB pen drive. The latter would be impractically too slow to support applications that require  handling thousands of files.

There is no portable Java for Windows yet (shame on Sun, I mean, Oracle). But it is known that an existing Java installation on Windows may be copied anywhere, like an USB hard drive. This copy will work with some minor adjustments (like manually setting path to the java/bin directory). On Linux things are much easier, since the Java installer just extracts the content anywhere and does not require administrator permissions.

This is what I did. First I installed the most up to date Java Runtime Environment on my Windows XP machine (or virtual machine if you don’t want to waste a physical machine for Windows). Then I unzipped Eclipse on the USB hard drive. As expected, Eclipse was not able to find the Java Runtime Environment installed on the same USB hard drive. That was very easy to fix by just editing the eclipse.ini file to point to the Java copy that is on the same disc.

Here is how the directories are organized on the USB hard drive. Just to avoid problems, do not use directory names with spaces.

WD Passport (F:)
   eclipse-3.5.2
      eclipse.exe
      eclipse.ini
      ...
   jdk1.6.0_18
      bin
         java.exe
         javaw.exe
         ...
      ...
   ...

And that is how the eclipse.ini file looks like:

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.java.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
f:\jdk1.6.0_18\bin
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx256m

There is just one issue, however: Each Windows machine mounts the USB drive as an arbitrary drive letter. Today I manually edit the eclipse.ini file if the USB drive letter changes. The only solution I imagine would be a script that rewrites the eclipse.ini file whenever the drive letter changes.

2 Responses to Running Eclipse on a machine without Java

  1. Davi says:

    You don`t need to change anything. Just rename the JRE folder to “jre” and put it inside eclipse folder.

    Eclipse laucher looks for this folder before quering the configured JRE or system JAVA_HOME.

    Also this works for your RCP application as well.

    Regaards,

    Davi

  2. Diogo says:

    It is also possible (in Windows) to use the absolute drive path, this way there is no problem if the pendrive gets assigned a different drive letter:
    -vm
    \jdk1.6.0_18\bin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: