Monday, November 27, 2006

The external drive conundrum

My Enterprise Java course got off to a rocky start. How rocky? Let's just say I was still doing exercises for the first week in week six. Why?

The difficulty begins with Eclipse. An Eclipse project is stored entirely in a virtual directory. The directory's name is the same name as the project. However, that virtual directory is mapped to a physical location on the machine. In my case, I had a project called Novus. It mapped it to my F: drive. (Being able to designate a relative path from the executable's directory in the project's properties would have been a quick fix!)

Now, toss in the fact that I'm running from an external USB drive. In class I was connecting as drive E:, in the lab I was connecting as drive F:, and at home I was connecting as F:, G:, or H:!

Yes, if I really wanted to, I could have gone to My Computer, right-clicked on "Manage" and selected Disk Management, removed the drive and reassigned it a letter. That was my first clue. However, still quite a hassle.

Meanwhile, I had to keep working. This meant I ended up with 2 or 3 different projects all at various stages of progress and none working due to the virtual path mapping in Eclipse. I needed some way to get everybody working on the same drive letter in Eclipse (since I could find no way to change Eclipse's mind and our instructor insisted we use Eclipse)

So I took my furthest project, recreated it from scratch, mapped it to the F: drive (as F was in common for all the computers (the classroom computers had F: available at least)) and then did the following:

All throughout, due to the nature of working from an external drive, I've been having to run a batch file in a command window to set various variables like JAVA_HOME and extend the PATH variable to include important directories on my drive. The variables were only avaiable to me within that particular command window, however, the key was the SUBST command:

subst [drive letter for virtual drive] [physical directory assigned to drive letter]

Now instead of having to use a wild character in my batch file for the drive letter, I could use f AND also virtually map my drive's physical location to F: as a virtual drive. Additionally, the subst command had an affect on the system, not just the command window's environment so Eclipse was also fooled into thinking my drive was on F: even while it was originally auto-assigned another letter by windows. Additionally, the subst command has no adverse affect if my drive is already on f and I run my batch file. The resulting batch file was thus:

subst f: .
set PATH=f:\svn\bin;f:\ant\bin;f:\PuTTY;f:\tomcat\bin;%PATH%
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_07
set SVN_EDITOR=notepad

Now instead of navigating through the manage window and so on, all I have to do is this:

Windows+R (launches the run dialog window)
cmd (to run the command window)
*: (where * is the drive letter my external drive is currently mapped to by windows)
setup

And I'm off and running!

This means that when I'm finished, I could log onto any computer with a high-speed connection, attach my drive, run setup, launch tomcat and wham: instant website from any location.

Next time: RSS Feed? What's that?

(Note to instructor: The previous entry was held as a draft until permission was obtained to post. 5 days past between blog entries, just not publication of blog entries)

0 Comments:

Post a Comment

<< Home