Disclaimer: I am not an investment advisor. When I describe my own trading activities, it is not intended as advice or solicitation of any kind.

14 October 2011

Applications: Moneydance

See Time For a Change for the first in this series, or view the index to see all the posts dealing with Arch Linux. This time I get Moneydance installed and functional, despite Oracle's best attempts to thwart me. This one should not have been this hard.

Personal Finance - Failed First Try
Microsoft Money was the best personal finance manager I've ever used, but Microsoft withdrew support for it a couple of years ago. And neither it nor Quicken run on Linux, anyway, so I was forced to find a new program. After trying a few, the best one I could find was Moneydance. It has all the quirks of an open-source program, but it costs money. Feh. The quality bar seems to be pretty low for personal finance management programs.

Installing Moneydance starts with downloading a script from their website. Running it, I get:

Could not display the GUI. This application needs access to an X Server.

Two Steps Forward
Insta-fail! I have an X Server, you morons. I did a little searching around on their website and didn't find much. But I did notice that the file downloaded from the link above included an embedded java runtime. I decided I might try one without the embedded java, and that turned out to simply be Moneydance itself, without an installer at all. That was fine with me... I did the same launcher-creation magic that I did with ThinkOrSwim yesterday, and Moneydance was ready to go.

A personal finance program is useless without finances, though, and I certainly don't want to throw away all my records from my old machine and start fresh. How to transfer files from the host to the guest? Well, VirtualBox has a great way to do that. I can specify a folder on the host machine to share with the guest. In a Linux guest like Arch, this shows up as a device that can be mounted, allowing me to simply copy files around. I right-clicked the wee folder icon in the bottom-right of the guest's VirtualBox window, and added a folder on the host (real) machine I want the guest (virtual) machine to see. I chose my home directory, giving it full read-write access in case I need to copy files back sometime.
The wee folder icon
Then I mounted the directory in the guest like this:

$ sudo mount -t vboxsf hildehome /mnt/hildehome/

The first "hildehome" is the name I gave my shared folder in VirtualBox ("hilde" is the name of my host machine), and the second, "/mnt/hildehome/" is the directory in the guest at which I want it mounted. Sure enough, after executing that command, I could see the contents of my host's home directory. So I simply copied the "money.md" file containing the last few years of my financial activity from my host's Documents folder to the same folder on the Arch guest machine, and then launched Moneydance. It asked me what I wanted to do, and I chose "Open an Existing File", and HPFM! it looked just like it did on my host machine.

One Step Back
I have an extension installed on the original machine that downloads stock prices from the internet and updates them in Moneydance so I know the current value of my investments. For some reason, Moneydance refused to acknowledge my click on the "Yes, please install" button. More searching on the website, and I discovered that the problem is that for Java I'm using the OpenJDK instead of the Sun JRE. Moneydance Support's advice is to use the Oracle JRE (used to be the Sun JRE until Oracle pulled a Borg on them), but that no longer works now that (F-ing, Evil) Oracle has removed its license to let Linux distros redistribute the Oracle JRE.

I did some looking on the Arch Wiki, and I can still install the Oracle JRE if I do it via the Arch User Repository (AUR). But apparently because I installed the OpenJDK already, that keeps OracleJRE from getting installed; and I can't remove the OpenJDK to replace it because KDE itself requires it. Great.

A Different Approach
What if I install it manually, by downloading the JRE directly from Oracle, the way a Windows user would? After accepting the hell-spawned license agreement and downloading the tarball, I extracted it into a working directory. Inside was a complete Java installation that required no secondary installation, so instead of doing anything fancy, I copied it to a system directory and set up an easy-to-use link.

$ sudo mv ~/abs/jre1.7.0 /opt/
$ sudo ln -s /opt/jre1.7.0 /opt/oraclejre

Now, in theory, I should be able to point any Java-using app to that location instead of the system-default OpenJDK, which is installed at /usr/lib/jvm/java-6-openjdk. So let's look at the script that runs Moneydance. I've trimmed out some script glue to show what's really going on, and I've numbered the lines for reference (the line numbers are not part of the script):

  1. MDHOME=`dirname "$0"`
  2. JAVA_EXE=java
  3. if [ -x ${MDHOME}/jre/bin/java ] ; then
  4.    JAVA_EXE=${MDHOME}/jre/bin/java
  5. fi
  6. exec "${JAVA_EXE}" -mx512m -cp "${MDCLASSES}" Moneydance "$@"
Line 1 finds the directory in which the script is running and assigns it to the variable MDHOME.  Line 2 sets a default path-based location for Java, essentially defaulting to what a user would get if he typed "java" at the command-line. On my machine, that's the OpenJDK version, which we already know doesn't work. Lines 3-5 test to see if there is an executable named "java" in the .../jre/bin directory under where the script is running. If so, it will use this one instead. This allows overriding the default system Java. Finally line 6 runs Java in the location chosen, and passes the necessary parameters to get Moneydance running.

The best way for me to trick Moneydance into using my newly installed OracleJRE, without changing this script, is to simply create a link in my Moneydance directory over to where the OracleJRE is. Moneydance's launch script will detect this, and use the OracleJRE. I'll run a few commands below to assure myself I'm doing what I think I'm doing, but the only really essential one is the "ln", which I have helpfully bolded.

$ java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.3) (ArchLinux-6.b22_1.10.3-1-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
$ /opt/oraclejre/bin/java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
$ ln -s /opt/oraclejre ~/moneydance/jre
$ ~/moneydance/jre/bin/java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

Looks good! When I next ran Moneydance, not only did it come right up as before, but I was able to install and configure the Stock Quote Updater plugin. And my portfolio went up today! Win-win!

Four down, six to go!

  • PasswordSafe for secure password management
  • Moneydance for personal finance DONE!
  • ThinkOrSwim for option trading DONE!
  • Minecraft - thought this would be easy, but it crashed on my first attempt
  • Dropbox for cloud storage
  • Kontact for e-mail, contacts, and calendar
  • Choqok for micro-blogging (following and posting to Twitter) DONE!
  • NixNote for notes/personal organization
  • Okteta hex editor DONE!
  • Bacula for automated backups

  • Next: Dropbox
    Or check out the Index

    No comments:

    Post a Comment