Making jEdit Run Correctly on Vista

I recently got a new computer at work, running Windows Vista. I’ve had Vista on my home computer for almost a year now, and I like it; it improves on XP in many ways. The UAC hadn’t caused me any issues at home, but it’s been involved in a few problems on this new computer.

I say “involved” because the problems aren’t really the fault of UAC, but of the programs running afoul of it. We’ll use my installation of jEdit as an example.

Installing jEdit

I downloaded the Windows installer, ran the EXE, and clicked “Continue” and “Allow” to let it run as an administrator. Installation went smoothly, and the installer launched the program; so far, so good. I proceed to install a few plugins, set a few preferences, etc.; all is well. Then I reboot my computer after installing some other software…

When I try to open jEdit again, the program freezes. So I kill the javaw process and try again: same result. Try running it as an administrator: it opens just fine. What’s going on? I didn’t have any problems with it on my home computer.

Tracking Down the Bug

Now that I have the program open as an administrator, I can look at its activity log. What do I see?

Log: user.home=C:\Users\lits

C:\Users\lits isn’t my home directory, it’s C:\Users\jmbrinley. lits is the username for the IT department that initially set up the computer for me. jEdit is trying to access files in another user’s home directory, and UAC is (rightfully) preventing it.

Where does jEdit get the idea that C:\Users\lits is my home directory? It seems to be related to a six-year-old bug in Java, by which user.home does not necessarily equal the %USERPROFILE% environment variable. It might equal another user’s home directory, or the home directory of a user that no longer exists, or the former home directory of the current user. There’s no way to know. It seems I just got lucky when I installed at home.

The Workaround

You can work around this by explicitly setting user.home when you launch Java.

  1. Find the batch file jEdit made when it installed (probably at C:\Program Files\jEdit\jedit.bat).
  2. After the path to the Java executable ("C:\Windows\system32\javaw.exe" on my system), add the flag -Duser.home=%USERPROFILE% so that the whole batch file looks like:
    @echo off
    start "jEdit startup" "C:\Windows\system32\javaw.exe" -Duser.home=%USERPROFILE% -Xmx192M -jar "C:\Program Files\jEdit\jedit.jar" -reuseview %*
  3. Find any shortcuts to jEdit, and change the target to "C:\Program Files\jEdit\jedit.bat" (use the path to your batch file, if different).
  4. If you have “Open with jEdit” in your Explorer context menu, open your registry and go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with jEdit\Command. Set the default string to "C:\Program Files\jEdit\jedit.bat" "%1" (again, use the path to your batch file, if different).

jEdit should now be in working order. I’d prefer to set user.home using an environment variable, to fix it across all Java programs, but I haven’t figured out how to do that, yet. In the meantime, this workaround gets the job done.