Run Java IDE using JDK and JRE on USB Drive?
I'm using a custom Java IDE written in Java. I'd like to give my 10th grade students USB Drives with the JDK and the IDE pre-installed. I'd like the students to be able to shuttle their work back and forth from home to school without altering any pre-existing Java configuration on their home computer. Some parents are very touchy about installing anything that might change the behavior of existing applications, including any Java apps, so I'd like to keep everything local to the USB drive if possible.
As with other IDEs, this one lets me indicate the path to the compiler on the stick, which works fine, but the IDE itself is executing from a JRE on the computer if one already exists. I'm assuming that this is do to the settings of the JAVA_HOME environment variable. I'd like to launch this IDE with the JRE that's on the USB Drive instead of any pre-existing JRE that may be on the PC.
Could I simply create a batch file which temporarily sets JAVA_HOME to the root Java directory on the USB drive (e.g. D:\JDK6) and then invoke the IDE? Would this force the execution of the IDE using the JRE on the USB Drive?
The other tricky thing is that I won't know what the drive letter is of the USB drive since they are assigned dynamically, unless there's a way of determining the drive letter of the drive from which the batch file is being run and using that as a variable in the batch file.
Any guidance would be appreciated,
- John K
[1487 byte] By [
kirkilja] at [2007-11-26 17:34:53]

> I'm using a custom Java IDE written in Java. I'd like
> to give my 10th grade students USB Drives with the
> JDK and the IDE pre-installed. I'd like the students
> to be able to shuttle their work back and forth from
> home to school without altering any pre-existing Java
> configuration on their home computer. Some parents
> are very touchy about installing anything that might
> change the behavior of existing applications,
> including any Java apps, so I'd like to keep
> everything local to the USB drive if possible.
>
Sound practice, should work. But beware that it'll be terribly slow as USB stickdrives (especially the cheap ones you're likely thinking of due to budget constraints) are far slower than are harddisks.
You're better off installing a JVM on it, a batchfile to launch a command prompt with the necessary environment settings, and a simple text editor like VIM.
Less performance impact, and they will learn to use commandline tools and set up their systems properly at the same time (and taking less space you may even get by with buying smaller, thus cheaper, devices).
> As with other IDEs, this one lets me indicate the
> path to the compiler on the stick, which works fine,
> but the IDE itself is executing from a JRE on the
> computer if one already exists. I'm assuming that
> this is do to the settings of the JAVA_HOME
> environment variable. I'd like to launch this IDE
> with the JRE that's on the USB Drive instead of any
> pre-existing JRE that may be on the PC.
>
You should be able to set it up through its own configuration (startup script or config file) to use the JVM on the stick.
Be sure to pick software that doesn't use the registry on the user's machine or home directory to store anything of course.
The settings would still change when moving to another system.
> Could I simply create a batch file which temporarily
> sets JAVA_HOME to the root Java directory on the USB
> drive (e.g. D:\JDK6) and then invoke the IDE? Would
> this force the execution of the IDE using the JRE on
> the USB Drive?
>
Sure. The system environment can be set in a command shell and will be valid for the lifetime of that shell.
If the IDE doesn't use the environment to find its Java runtime (but most likely the system registry) you're out of luck though (but see above, you shouldn't use such an IDE for a project like this anyway).
> The other tricky thing is that I won't know what the
> drive letter is of the USB drive since they are
> assigned dynamically, unless there's a way of
> determining the drive letter of the drive from which
> the batch file is being run and using that as a
> variable in the batch file.
>
You don't need to know. Just use relative paths from the root of the drive and it should work.