views:

984

answers:

3
+3  Q: 

Portable Eclipse

I'm trying to port my entire 'workspace' to a USB key (including the Eclipse executable) so that I can carry my work anywhere with me and work off the key directly.

My directory hierarchy is similar to this:

/workspace/eclipse - Where my current eclipse binary is stored
/workspace/codebase - Where I keep the root of all my eclipse projects
/workspace/resources - Where I keep all project files (images, docs, libs, etc.)

It all works perfectly fine on one system. But when I change over to another system, the USB key gets mounted on another drive. For example, on my laptop, I get 'E:\', on my PC, I get 'K:\' and at work I get 'F:\', etc, etc.

This means that because Eclipse (for 'some' reason) seems to only use full path names (including driver letters) in every single one of its configuration files (such as .classpath), nothing ever works when I want to work on another system.

I put a 'libs' directory in the base of every project and populate it with its dependent JAR files. Why doesn't it use relative names instead, so that I could specify something like "../../libs/log4j.jar"?

Anyone know how to fix this problem? Does anyone know of a workaround for this?

For some reason, I really doubt I'm the first developer to do this!

Thanks for your help and any suggestions.

+5  A: 

Have you tried using Eclipse Portable. Works fine for me. The only thing I have to keep in mind is then switching the workspace I need to remember to give it relative path (like ../../Data/workspace).

RaYell
Never heard of it... but I'll look into that right now, thanks!
Jeach
When I clicked that link it said "outdated" and led me to another page which was also "outdated" and so on until I got to one that appears to be the newest version. I edited your answer to link to the new version.
MatrixFrog
+4  A: 

You could use the dos command subst to get a consistent drive letter by creating a new virtual drive letter (say x:) that maps to your Eclipse folder on your usb drive, and then make all the config paths reference the drive x:

You could make a little batch file on the usb drive that you click on to create the drive x:

C:\>help subst
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.
Matthew Lock
+1  A: 

You could also remap letter for your USB stick in Windows Disk Management (subitem in Computer management) to be smth like 'U:'. Once done, it will be re-assigned to same stick every time you plug it. Not very universal, since your user need rights to access this setting first time, but it could help in some different scenarios.

bybor