The IDE Wars: NetBeans or Eclipse for Java Software Development

I’ve been working on several applications for a few years; some are ready or released into the wild. I’ve used NetBeans and Eclipse to develop one application in particular; I’ve written an Earthdawn dice roller application. Earthdawn is like Dungeons & Dragons, but for real nerds. The Earthdawn dice system is complex, including a shifting iterated seven-step algorithm for determining the dice rolled for a given action. In addition, dice explode in Earthdawn. That means that if a given die results in its maximum value (i.e. a d6 result is a 6 or a d12 result is a 12), you reroll the dice and add that to the total, continuing to reroll if the die continues to result in its maximum value and stopping when it does not. Plus, you also have the option of adding a karma die (dependent on race, like Elf or Dwarf) to any roll which permits it.

Obviously, this is a complex system, and dealing with the RNG was not the hard part. The hard part was
figuring out the algorithm by which you can calculate the dice you would roll for any given step. For example, rolling a step 10 means that you roll a d8 + d6. Rolling a step 20 means that you roll 2d12 + d10. You can find this on a chart in the 3rd Edition Earthdawn Player’s Guide, but it actually took doing a Taylor series to determine that there is an algorithm which repeats every 7 steps. This means that my app can calculate what you’d roll for a step 63 dice roll, when the book doesn’t provide a chart that high.

I’ve been fiddling with this app for a year or so, and while I’ve been developing the backend in Eclipse, I found that the frontend needed some serious help. I looked around for an IDE specifically to develop the frontend of a Java app, and NetBeans turned out to be full-featured enough to develop in much the same way that I’d dev a C# app in Visual Studio 2010. I’m an old school algorithm coder, and I don’t do as much frontend app development, as opposed to my long term work in
frontend web development. In fact, most of my experience in frontend app development is in VS from 2003 on. So, believe it or not, I was looking for an IDE experience closer to VS.

NetBeans is open source; I found that specifically for the purpose of frontend Java software development, it’s a far better IDE than Eclipse. While Eclipse works better for academic algorithm coding, NetBeans is tailor-made for someone who wants to turn out an app with a backend; in fact, I coded the backend over rather a lot of time in Eclipse to test it with multiple RNGs developed at CERN, Argonne, etc, and simply copied over the relevant classes into NetBeans to hook them up to the frontend. I’d actually recommend this as the most efficient experience if you’re trying to create a complex backend with a simple and effective frontend…especially if you have an app that needs a frontend instead of a script. NetBeans has a simple application package process as well, if you need to pack up the app and send it out. I have
Ubuntu, OpenSUSE, Windows, and Mac users in my group, and Java will execute on each of those platforms.

I’ll also shortly be posting the app so you can examine it for yourselves 😉

How to SSH into your home computer to access media files, documents, processes, or anything else you might need

I wanted access to my home machine so I could access any files I want. Dropbox is pretty awesome, but if you’ve forgotten to put something in your Dropbox folder, you’ll be in deep trouble.

(1) Run “sudo apt-get install openssh-server” at the command line.

(2) Run “sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original”. This copies your original configuration file for SSH so if you muck up the settings, you can always replace them.

(3) Run “sudo kate /etc/ssh/sshd_config” (or whatever text editor you use) and change the port number from 22 to another port so you won’t be targeted by so many bots.

(4) Ensure that your firewall isn’t blocking the port you chose. You may need to add SSH as a running service. You should probably also include ‘sshd’ as a startup application in your distro so that if you need to do a remote reboot, the service restarts and you can log back in.

(5) Forward the port
being used for SSH in your router. To do this, you need the internal IP address of your computer on your home network, as I presume you’re not dumb enough to directly connect your home machine to a modem. Ask me if you have problems figuring out how to forward the port.

(6) Get out your Android phone if you have one, since a connection over 3G will mean that you can test your SSH connection without ever leaving your comfy chair. Install ConnectBot through Android Market.

(7) Open ConnectBot (or any SSH client from any machine; Putty will work well) and type in your home machine username, your external IP address, and if you have changed the port, include that as well. Here’s the format: username@ Where is your external IP address and XXXXX is the port number you chose to replace the default.

(8) If you have issues getting a connection, hit me in the comments; I had several oddities in router configuration making this work, even though it’s
quite simple in theory.

How to batch scan using Xsane

If you’re like me, you can’t throw important documents away, but there’s no easy way to scan old records, tax documents, and all the crap you’re supposed to save for 7 or 10 years…or however long taxes are supposed to stick around. Unfortunately, batch scanning with Xsane using an ADF (auto document feeder) is not even remotely intuitive.

Here’s how to do it (I have an HP Officejet 6500, a relatively common all-in-one printer using hplip for drivers):

(1) Open Xsane. Choose the correct printer/scanner; it’s likely to be the top one in the list.

(2) There’s a tiny ticker field in the top left corner of the main Xsane window with no label on it. Set that to 40 or so (however many documents your ADF can take at a time, plus 5 or 10). You do that because if you leave it set at 1, Xsane will assume that you only want to scan the first document in the ADF. This way it knows to look for 40, and will quit afterwards. The
other alternative is to set it at 30 or so, and push the scan button again after it’s stopped (if there are documents still in the ADF).

(3) Set the dropdown on the top right to “Multipage”. Ignore “batch scan” and the advanced settings.

(4) Create a working directory, and be sure to chmod and chown that directory recursively.*

(5) Create the multipage project in that directory. Set the output to PDF (if that’s what you want. PDF is probably best for archiving documents).

(6) Put a load of documents into your ADF, and hit ‘scan’ in the main Xsane window.

(7) Once they’re done, either load more and keep hitting the scan button to do batches of documents, or hit the “save multipage file” button at the bottom of the multipage project window.


*You may have issues using the multipage project mode in Xsane if you don’t have proper read/write permissions set on your directory.

Open a terminal.

Enter at the prompt: sudo
chmod -R a+rwx /yourHome/yourWorkingDirectory

Enter at the prompt: sudo chown -R yourUserName /yourHome/yourWorkingDirectory

Triple booting Linux distros with a mix of GRUB2 and GRUB legacy, Part 2

Instructions on how to multi-boot with a mix of legacy and 2.

DISCLAIMER: this method erases your entire hard drive and repartitions it. If you are uncomfortable mucking about with partition tables, go look at some beginner resources and tutorials on fdisk, gparted, and disk partitioning in general. This is not a method or tutorial intended for n00bs; there are some advanced concepts here. Be prepared to start from the beginning a few times if you mess up; since you’re wiping and repartitioning from the start, you won’t have lost anything but time. I restarted this a couple of times before I got it right.

THEN I wrote it down so I could look all smart and stuff.


    (1) Determine in advance which distros use legacy and 2.

    (2) Pick the legacy distro which has the easiest, most
    attractive boot screen. In my case, it was openSUSE.

    (3) Get ready to use that one first.

    (4) Use an Ubuntu LiveCD (even if you’re not planning on installing this distro, since the Ubuntu LiveCD is the most intuitive and useful) to boot from CD. Do not install anything at this time.

    (5) Using your favorite disk partitioning tool (gdisk, fdisk, gparted, etc), partition your hard drive into: (1) a teeny boot partition; (2) swap area; (3) root partitions for each of your distros that are at least 10GB in size; (4) home partitions for each of your distros that are at least 10GB in size; (5) a mega big data partition.

    (5a) To install and use gdisk from the Ubuntu LiveCD, open a browser, go here:, download it to any folder (the default will be /Desktop), open a terminal shell, navigate to that folder, and use this command: sudo dpkg -i gdisk_0.6.10-1_i386.deb.

    Instructions on using gdisk (with thanks to srs5694 from the Ubuntu Forums) if necessary:

    (5c) Boot an Ubuntu installer or an emergency disc, like Parted Magic or System Rescue CD. If using an Ubuntu installer, boot it into a recovery mode so that you can get a shell rather than booting straight into the installer.

    (5d) Launch a text-mode shell. If you’re using an Ubuntu installer, type “sudo apt-get install gdisk” to obtain and install GPT fdisk (gdisk). If this doesn’t work, use the method I described above to get gdisk.

    (5e) Type “sudo gdisk /dev/sda” (you can omit “sudo” on some emergency disks).

    (5f) Type “o” and answer “y” to the verification prompt to create a fresh partition table. Note that this will wipe out all your existing partitions.

    (5g) Type “n” to create a new partition. Give values of: partition #1, start sector 2048, end sector +1M, hex code of EF02. This creates the BIOS Boot Partition.

    (5h) Type “n” to create another new
    partition. Give values of: partition #2, hit enter for the default start sector, end sector +20G (or however big you want the Ubuntu main installation to be, minus space for your user files), hex code of 0700 (the default). This creates what will be the Linux root (/) partition.

    (5i) Type “n” to create another new partition. Give values of: partition #3, hit enter for the default start sector, end sector +2G (or however big you want to make your swap space), hex code of 8200. This creates a Linux swap partition.

    (5j) Type “n” to create another new partition. Give values of: partition #4, hit enter for the default start sector, hit enter for the default end sector (to use the whole disk), hex code 0700 (the default). This creates what will be the Linux /home partition. If you want other partitions, you should set some other end value and create additional partitions at this point.

    (5k) Type “p” to review your partition table. It should have an EF02 BIOS Boot Partition, two
    Linux/Windows data partitions, and a Linux swap partition. If it doesn’t, correct the problems or quit by typing “q” and start again.

    (5l) Type “w” to save the partition table.

    (5m) If necessary, reboot into the Ubuntu installer; or just launch the installation process. When you get to the disk partitioning section, tell the system to do custom partitioning, but do not start from scratch. Instead, tell it to use /dev/sda2 as root (/), /dev/sda3 as swap, and /dev/sda4 as /home. (Adjust these partition IDs as necessary, if you deviated from the numbers I specified earlier.) The installer will create new filesystems or swap space on these partitions. You should not tell the installer to do anything with /dev/sda1; when the system installs GRUB, the GRUB installer should use /dev/sda1 automatically.

    (6) Now, install your chosen legacy distro to the first root partition you want, with its data at its own home. Mount the big data partition as /data or whatever you want. Do not mount
    the other partitions; those are for your other distros.

    (6a) When installing the bootloader, specify that it’s to be installed to the hard disk. Grub legacy will find the mini partition and do its thing.

    (7) Check to find out if the BIOS partition has its boot flag flying.

    (7a) Boot a live disk of some kind; Ubuntu LiveCD works.

    (7b) Launch a shell.

    (7c) Type “sudo fdisk /dev/sda”.

    (7d) Type “p” to view the MBR partition table. It should show one partition, with “ee” in the “Id” column. This is normal, even though you created several GPT partitions. Is there a ” * ” under the Boot column? If not, proceed with steps 7e-7h.

    (7e) Type “a” and enter “1” (or whatever the partition number is) when prompted.

    (7f) Type “p” again. You should now see an “*” under the “Boot” column.

    (7g) Type “w” to save the changes.

    (7h) Remove the emergency CD and reboot. You should not need to re-install.

    (8) Install the other
    distros to their own root partitions; the legacy ones first. You may need to reflag the BIOS boot partition after each install; you DEFINITELY need to specify that each distro’s bootloader is to be installed to its own root partition. IF YOU DO NOT DO THIS, YOU MAY OVERWRITE THE BIOS BOOT PARTITION AND NEED TO START FROM THE BEGINNING.

    (9) Install any Grub 2 distros, also specifying the bootloader installation to their own root partitions.

    (10) Run sudo update-grub from your first distro. After booting, check to make sure that you have boot options for each of your other distros. If not, you may need to add chainloading boot entries.

    (10a) For further discussion on chainloading (dead simple and requires minimal editing of your /boot/grub/menu.lst file), see here:

After each install, I checked, updated grub, added the relevant entries, reflagged the boot partition,
and by the time I was done, I was triple booting.

Any questions?

Triple booting Linux distros with a mix of GRUB2 and GRUB legacy, Part 1

I’ve been experimenting with other distros. I just got a 2TB internal Western Digital Caviar Black, and there’s just too much room there NOT to create nine partitions and get my distro freak on.

I know, Kubuntu baybee, but it’s not you, it’s me. I just can’t stay faithful to one distro, and you KNEW that when you seduced me with your ease of installation, friendly user community, and sexy Compiz+KDE desktop. Let’s still be friends, and you’ll always be my main squeeze.

As with so many other things, as long as you know how to do it, it’s easy. If you don’t, it will be the little things that trip you up. In my case, it is a buggy BIOS version. I have to reflag the BIOS boot partition each time I install another OS.

Should you want to be Crazy In Love with many different distros, you are likely to run across the issue of a mix of GRUB legacy and GRUB2. These are bootloaders–the things that make your hardware know what
software to run. There’s a leetle tiny bit of code at the beginning of each bootable hard drive that tells your machine that there’s an operating system available to run the machine. That’s the MBR–the master boot record.

I had a hellacious time figuring out why my BIOS wouldn’t find a working OS any time I installed a grub legacy OS to another partition (since grub2 was loading my Kubuntu installation). I still don’t know why chainloading grub through grub2 will NOT work with my BIOS, and chainloading grub2 through grub legacy works like a dream, but it seems like the sort of arcane knowledge only possessed by Elminster or Gandalf.

So, the recommendation from yours truly? Use a grub legacy distro to write to the MBR and use that to chainload grub2. Instructions to follow in the next post 😉

An update to the bash script that takes a parameter:



[[ -z $book ]] && { echo “No argument supplied, exiting!”; exit 1; }

[[ ! -e $book ]] && { echo “Can’t find a file with the name $book, exiting”; exit 1; }

sed -i ‘s/\r$//’ “$book”
while read line
if [[ $linecounter -gt 300 && -z “$line” || -z “$output_file” ]]; then
formatted_bookcounter=$(printf “%03d” $bookcounter)
echo “…starting segment $output_file”
echo “$title – segment $formatted_bookcounter” > $output_file
echo “===================” >> $output_file
echo “” >> $output_file
echo “$line” >> $output_file
done < "$book"

Get emailed a portion of classic literature each day.

Ok, so I am feeling guilty over not reading enough GOOD books.

So, I devised a cunning plan whereby I am emailed a portion of a classic book each day. I started with the Iliad. I know that I’ll clear my emails every single day because a cluttered inbox irritates me…so this is the perfect motivational tool. I wrote each of these scripts (with occasional help from the lovely folks who hang out with me in Programming Talk at the Ubuntu Forums), and this is the way I did this.

(1) Download a book you want to read. I suggest starting with something like the Iliad or Ovid’s Metamorphoses. Poetry is a great way to start; it’s episodic and fun. Head to to find text versions of any book you want. Other suggestions: the Aeneid, any Shakespeare play, the Divine Comedy, Paradise Lost, etc.

(2) Drop it into a folder, renaming it ‘[whatever].txt’. In my example, I’m dividing the Metamorphoses.

(3) Navigate to
that folder at the CL.

(4) Run this script to divide the book up into 300 line segments (or, if there is no paragraph break at 300 lines, the script will add more lines until a paragraph break is reached. That way, you don’t end up getting half a soliloquy). Obviously, if you want to read more or less each day, change the number of lines to however much you want:

sed -i 's/\r$//' metamorphoses.txt
while read line
if [[ $linecounter -gt 300 && -z "$line" || -z "$output_file" ]]; then
formatted_bookcounter=$(printf "%03d" $bookcounter)
echo "...starting segment $output_file"
echo "Metamorphoses - segment $formatted_bookcounter" > $output_file
echo "===================" >> $output_file
echo "" >> $output_file
echo "$line" >> $output_file
ndone < metamorphoses.txt

(5) In your folder, delete the big file. You should now have several (or possibly several dozen or hundreds) of much smaller files, numbered consecutively.

(6) Then, run this script (Adds a subject header to each of the files in your folder) :

for f in $FILES ; do
sed -i '1s/^/Subject:Your Daily Book Part, Tarah.\n/' "$f"
cat "$f"

(7) Then, add this script to wherever you store your scripts. It sorts the files in your pet directory by number, gets the first one (i.e. 'metamorphoses024.txt') mails it to you, then deletes that file. Then, the next time the script is run, it will get 'metamorphoses025.txt' as the first file in the directory. Call it '' or whatever. NB: you must have msmtp installed to make this work. Ensure it's reachable through your path. Any other command line emailer will also work; I know how to use msmtp, so that's what I do. Plus, I use
Kubuntu, so it's available at the repos.

cd /home/tarahmarie/Documents/MyEbooks/aaa/
FILE=$(ls | sort -n | head -1)
cat $FILE | msmtp -a gmail
\rm `ls | sort -n | head -1`

(8) Execute '' at the CL to ensure it works. If, in a few seconds, you get an email containing the subject line 'Your Daily Book Part, WhoeverYouAre', then the command is working. If you're having any problems, ensure that you have permissions to each of these scripts, and that they're marked 'executable'.

(9) Add '' to your system's list of scheduled commands. I use kcron, so I set '' to be executed each day at 8AM.

(10) Feel superior to other humans for the fact that you're reading a 'good' book every day. This is DEFINITELY how I'm going to get all the way through War and Peace. Eventually. Let us not even speak of Remembrance of Things Past. I will CONQUER you, Proust, ole buddy.

Simple tip to make Android easy to access…

…via your home wifi server.

(1) Install On Air from the Android Market.

(2) Ensure that your home wifi is accessible through your phone’s Settings menu.

(3) In On Air, set your preferences to “use the same 4-digit code”.

(4) Hit the big button to turn on the FTP server on your phone.

(5) In your chosen file manager (mine is Dolphin), FTP into the phone, using the 4-digit password generated by On Air. Save the password, and bookmark/save that FTP location to your Places view or some easy place to find it.

Bingo! Now, you only have to hit the big button on On Air and browse to that place in your file manager to remote-access your phone.