Linux Can’t load

Your a Java developer and you’ve installed Linux. Maybe this is your first time converting from Windows. Maybe you’re a Linux veteran trying Java for the first time. Maybe you’re new to both Java and Linux and you’re running some crappy program some other Java guy wrote. Whatever your background is, you now find yourself staring at an unstatisfied link error. You don’t know what angered the link and you have no idea how to satisfy it. Hi, I’m Cliff and you’re here because you suck at satisfying links. But we already knew that, didn’t we? Does the error below look familiar?

java.lang.UnsatisfiedLinkError: Can’t load library: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/motif21/
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.load0(
at java.lang.System.load(
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.loadLibrary0(
at java.lang.System.loadLibrary(
at Method)
at java.awt.Toolkit.loadLibraries(
at java.awt.Toolkit.(

The long answer begins, “four score and seventeen (…seven? …several?) years ago…” and continues with babbling about openjdk and motif libs with a bunch of other nonsense you probably don’t particularly care about. The short story (which is also why you’re here listening to the most long-winded developer this side of the east coast that loves to insert rambling between parenthesis as if that makes any of his blog posts easier on the eyes…) is that you probably need to unset or set an environment variable. “export AWT_TOOLKIT=MToolkit” will cause the error while “export AWT_TOOLKIT=XToolkit” should make it go away. The environment variable controls which one of Linux’s windowing toolkits are used to draw the program on your screen. The MToolkit causes the Java program to look for the “” file which is a Motif Abstract Windowing Toolkit Shared Object, hence the “m-a-w-t.s-o” in the file name. Shared objects are the Linux way of sharing code. Other operating systems use other files. Windows uses “.dll” files, while Mac OSX uses “dylib” files. The Abstract Windowing Toolkit is the Java way of drawing programs on your screen which is abstract so that it can change the way the program looks and feels. Motif is one of the many looks of a java program, while others include “Native”, “Metal”, “Aqua” and others. Not all of these looks are available in each distribution of Java so chances are that you copied a program from a system (or developed a program for a system) that included the Motif look and feel and now you’re trying to run it on your fresh Linux install.

The good news is the problem is easy to fix once you know the how and why. The bad news is you’ll probably do something clever like putting “AWT_TOOLKIT=XToolkit” in your “~/.bash_profile” and forget this hack is in place which will likely cause other issues several months down the line when you want to toy with Compiz-Fusion but your IntelliJ editor is acting funny, locking up or going completely dark or something. That’s your good-news/bad-news for the day. Happy coding and clever hacking to you all.

KMID- KDE MIDI playback on Mepis/Debian

I had a moment of inspiration last night thinking about driving games and this afternoon during lunch I decided to try to find the MIDIs for Rad Racer. This was one of my favorite Nintendo games. (I honestly think music can make/break a driving title. For eg. Sega’s Outrun was not as much fun because I hated the music.) At any rate I downloaded the file and went in Konqueror to open it. Konqueror knew nothing about MIDIs except that they sounded like an electronic keyboard so it labels the file with a cute keyboard icon prior to asking me which program should open the file. I’m like, “why are you asking me? I don’t feel like searching my applications for a MIDI app!” So I posted on MepisLovers in frustration prior to asking Google. Google led me to KMID which lead me to more frustration. Instead of posting another frustrated response to my thread I did more research. (I hate researching Linux stuff now because I feel like I should know it but just can’t remember so now I just get lazy and either give up or post on MepisLovers cause the people there are so responsive.) I was frustrated because the KMid Konqueror plugin complained about multi-part MIDI format and also because the KMid app only pretended to play the song. There were flashing lights and all but no sound.

Because I’ve dealt with the no sound on Linux issue so many times I was about to pull my skull apart. I exercised a little more patience and Googled for the answer which I’ll describe in short here. If you get no sound from KMid it’s because you need a MIDI synthesizer which does not come pre-installed in Mepis. The proper way to play a MIDI in Mepis and Debian based distros is to “apt-get install kmid timidity”. Then edit (as root) the /etc/default/timidity file and set “TIM_ALSASEQ=true” by removing the preceding hash or pound sign “#”. The apt-get installer will tell you to do this after it completes but most people will overlook this step. It should say something like:
Setting up timidity (2.13.2-20) ...
* Starting timidity * not yet configured * Enable Alsa Sequencer first by editing /etc/default/timidity [ OK ]
Processing triggers for menu ...

Finally restart timidity using:
/etc/init.d/timidity stop; /etc/init.d/timidity start
and set the output in KMid settings to use a timidity port. It looks like a bunch of steps but can be reduced to a couple of command line calls that should be packaged as a .deb file to be run as part of the KMid install process.

The SSH-wiss Army Knife

Linux Rox!I wrote about SSH port forwarding a while ago but I don’t think y’all heard me. Listen up. (Place your ear within mere centimeters of your monitor if you will so that I can scream at’cha.) SECURE SHELL IS TEH BEST TOOL YOU’LL EVER USE IN YOUR ENGINEERING CAREER! I’m writing today because I was reminded from an incoming blog link about the power locked in this three letter acronym: S-S-H

By itself it doesn’t look interesting. However, if you take a minute to learn what it means, what it does, and what it can do then you’ll see why the above sentence is in all bold caps. It’s one of those things that people take for granite, like the extra buttons on your microwave. If you’re like me (and you must be or else you wouldn’t be reading) then you probably never use anything other than the “quick minute” and start buttons on the microwave. The meat/poultry, popcorn, and reheat buttons are just for show and whether they function or not is just a mystery. That’s how most people see ssh. But, but… when you learn what goes on under the acronym you start to look at those other people like fools that literally drive 747 Boeing’s to/from work and complain when they get stuck in rush hour traffic.

Let me stop right there. Have you ever had that experience before? Have you ever found out how to really use something like your TIVO or VCR, or maybe it was all the hidden features in your car like auto off lights, tire pressure monitor, and the multi-user programmable power seat adjustments. Have you later watched somebody with the same equipment literally ignore/abuse the features? Here’s the tricky part. These very same people will look at you cross eyed as you spend hours/days trying to figure out how/why feature “X” will/won’t work while they have found the shortest most abusive 30 second path to gratification. There is something to be said of folks from both camps but I’ll leave that for after post discussion if you feel like commenting. (I’m waay off topic.)

So far I’ve found at least 7-10 good uses for SSH ranging from X11 forwarding to remote port forwarding to transparent access to remote Linux-based file systems, and more. I’m certain there are many more that I haven’t found or stepped into on my way to the shed to pull out my trusty dusty mower. What way do you use SSH? Do you cut it with a 5th of gin? Have you tried it with hot sauce? Does it work well as an antacid? Maybe you’ve manage to repair that hole in your vinyl upholstery with it. Whether you’ve fixed a flat or refinanced your mortgage with it I’d love to hear your story.

SSH tunnels and remote port forwarding

If you want you can skip the beginning blurb and go right to the recipe.

Every so often you face a tough problem then someone sayz to yuh, “Cliff, have you tried ssh tunnels?” (well that’s what hey would say to you if you were me, and if you were me you would have a habit of making easy problems way tougher than they need to be while you make tough problems easy.) That’s what happened to me a loooong time ago… like around last month. The I was chattin’ with the VP of technology about all things Maven and mobile related explaining how clever we were with our solution to on device testing when he suggested we try ssh tunneling. I read an article that day and got excited because it looked soo easy. Then I made a promise to our mobile dev team that I would prototype it over the weeken. Then I quietly forgot about it. Today the question came up again and I was like, “Oh crap! I never did try prototyping a solution to that problem!” I gave it a good hour of effort before getting stuck. It’s really not that difficult, and after leaving for the day, coming home and attacking it fresh I found that I only had one minor problem… I didn’t read the docs completely. (That’s how it goes when I see something cool. I jump in head first and complain because I always miss something simple and fundamental.) Silly babbling aside I present you the how to on what to do to get to your CPU thru EC2…
(or any other public remote web host)

1 Remote server running a flavor of ssh. (In my example I assume openSSH as it’s prevalent across many Linux distros.)
1 local computer that you desire to access also running a flavor of ssh (I’m using OS X in my example.)
2 Eggs slightly beaten whites removed.

1. Combine one additional parameter with the default sshd_config file under our server’s /etc/ssh folder. Use vi, nano, kate, gedit or a fancy command like the following.
sudo echo ” GatewayPorts yes” >> /etc/ssh/sshd_config
[For best results supply password when using the above crazy command.] The parameter name is GatewayPorts and the value should be yes to allow clients other than the server itself to tunnel into your local machine.

2. Execute one sshd restart command to allow the new parameter to be considered on the server. Eg.
sudo /etc/sshd restart

3. Add -R [remote port]:localhost:[local port] to 1 1/2 cup of ssh command typing slow to avoid error. The remote port is the port number you wish to tunnel through on the remote machine while the local port is the port you want all traffic to be directed to on the local machine. Eg.
ssh me@myremotehost -R 80:localhost:9002
This can be used to forward all web server requests to a server app running on the crappy Compaq that you used to execute the ssh command.

That’s it! The net result would be a service running on your desktop/laptop/MacBook in your garage appearing as if was running on the public remote web host. So then you point your browser to http://myremotehost and your home equipment gets all the traffic. The secret is the “GatewayPorts yes” property that must be set in the remote host’s /etc/ssh/sshd_config file. That secret value bypasses all common sense security allowing anybody on the internet to peek into your home located machine and access the pictures of you and the kids looking burnt up at Daytona Beach, FL.

Now why would you want to do that? There are all sorts of possibilities that arise when you start playing with tunnels. First off, they run through the security of secure shell, a robust tool that I’ve only begun to understand the capabilities of. (It seems like ssh can do everything from being a secure channel, to enabling sFTP, to being a mountable file system allowing Windows explorer like file browsing, to recording those 10:30am episodes of Judge Judy while you’re at work. Yes, ssh can do that too.) Tunnels work both ways, remote forwarding and local forwarding. If you were behind a firewall that allowed connections to remote ssh hosts but blocked some other port/protocol you could sidestep by doing something similar to the above but substituting the ‘-R’ with a ‘-L’ for a local forward. Then all the traffic sent to the machine you run the ssh command from would be forwarded to the remote host. It’s so simple! Setting up a tunnel is a matter of specifying the port you want to forward from and the port you want to forward to! Use your imagination, and happy port forwarding!

Use ALSA for OSX Sounds

A follow up to a much earlier post using the same idea I’ve modified my old command line shell script to handle .m4a and partially .aif files. The catalyst was my neighbor on the other side of my cube wall. He got tired of hearing my Kopete blips and I’ll admit they do sound annoying. So now I opted for the much softer TokyoTrainStationAdiumSoundset from Apple’s adium IM client. Pulling these sounds over was the fun part. Using Konqueror, I drill into my Mac with the “fish://” protocol and navigate to /Applications/Internet/ where all of my Adium sound sets await, eager to invade my hungry little ear drums. I copy them to a folder locally. (Alternatively I could have opened the Adium application bundle in Finder by command tapping or right clicking or two-finger tapping and choosing “Show Bundle Contents”. I could then use MacFuse/MacFusion which is always broken after a run of Mac Janitor and mount my Linux box to push the files over.) I then dump my earlier shell script somewhere in my path (I named it alsa-play this time) and use it to configure Pidgin. (The same will work with Kopete though I’m using Pidgin now because Kopete has been acting very funny. The big problem is that Kopete refuses to communicate with my buddy’s WinXP install of Pidgin… so many variables, so little time to chase them all!) I apt-get install faad which is a command line tool for decoding Apple audio files. Here’s the painful part, figuring out which command line parameters to pass to both faad and aplay. (aplay is the command line tool for jamming audio 1s and 0s into your sound card which, in turn, shoves these 1s and 0s down the thin black cable connected to your speakers which eventually convert the numbers into sound by rattling those pricey paper cones located inside their towers. Its amazing how much I’ve learned about audio… can you tell how much I love the study of sound?) After various iterations of producing garbled nonsense from failed commands I learned that I was missing an “-f cd” flag on aplay. Who would have known? I’m not even sure I remember what the flag means. Here’s the finished script. (Remember it assumes you have faad, oggdec, and mpg123 installed for conversion puurposes.)


case $1 in

   *.m4a|*.aac|*.aif) faad -w -q $1 | aplay -q -t wav -f cd

   *.ogg) oggdec -Q -o - "$1" | aplay -q &

   *.wav|*.voc|*.wav|*.au|*.raw) aplay -q $1 &

   *.mp3) mpg321 -o alsa $1 &

   *) echo "unsupported file type $1"

Broken screen resolutions in Mepis 7

It’s been a while since I’ve been entrenched in Linux. I used to know this stuff like I know karate. (I took all of two months of Taekwondo which were Tuesday and Thursday evening courses back in the 6th grade.) There was a time I could dcopfrom KMenu through Amarok and generate Growl-like messages when new apps were installed. Now it feels like a struggle. Today I figured out how to fix my screen resolution in my recent Mepis 7 install. There’s a page on the wiki I used as a guide. For whatever the reason my resolution was too low in Twin View mode after installing the NVidia driver (2048×768 combined resolution) leading to some huge fonts that I couldn’t understand and other oddities. The fix was as simple as adjusting the MetaModes in my xorg.conf file. The meta modes is what seems to control the available resolutions in the twin view display settings. Also, if you’re gamma-configuring inclined you may wish to apt-get install the nvidia-settings program to fine tune things like Open-GL and other egg head parameters that I’ll only learn about two years from now when I’m stuck on the toilet looking for reading material and decide to pull out the mobile and do some web browsing finally noticing only few sites look good on the 8830 Wikipedia being one and JoelOnSoftware the other.

KDE Katapult Tip

I’ve done this before, all of it. Everything I’ve done to my new Mepis box is a repeat of two years ago but a lot of it I can’t remember… too hazy. That’s why the blog posts.

Today’s tip involves Katapult. I fell in love with it because of the way it lists my album art as I incrementally search my music selection. I used to rate it above anything on the Mac until I actually tried a Mac. (Silly me, right!) After having been exposed to QuickSilver for a while (and to that extent even Launchy has a thing or two on Katapult!) I miss the ability to re-index my catalog. What that means is being able to see the things right after you install them. Quicksilver (and I think even Launchy) does this automatically on an interval and gives you the option of manually starting a re indexing. Katapult, sadly, only indexes on startup. So I have this one line bash command that you can stick in your KDE menu (so Katapult can see it) that will force a rebuild of the index.

dcop katapult MainApplication-Interface quit; katapult

It restarts Katapult and if you put it in your KDE menu (and stick the Katapult icon on it all nice and cute like) just as I did then you can invoke katapult, right after you do something like install Pidgin, or Groovy, then restart and the next time you bring up Katapult your new install will be there.

Fix Java Swing Apps on Compiz-Fusion

Or fix Swing apps on Beryl…

I’m keeping my eye on this trail:
I found it using this search:

Because I use Idea and because Idea uses Swing, and because I like eye candy, things just wont work 100% even on Debian/Mepis one of the most stable OSes around. If you use Mepis 7 out of the box then you’ll have a great experience. But if you’re like me then you’ll no doubt push the limits even a little and find your self looking at a blank screen when there should be a diff.

Creative Sound Blaster X Fi on Ubuntu Hardy

I got a lot to say but no time to say it. For now just know that I’m back on Linux and fighting with audio incompatibility. It sux because most everything else works on my fresh new Mint Linux (that’s right I’m on Mint now, not Mepis, not Kubuntu…) install. For what it’s worth I think my answers may be here. If you have a Creative Sound Blaster X Fi card and are considering installing the latest version of Mepis, (K)Ubuntu, or Mint, look at this guide:

There’s a blurb about SLAB vs. SLUB don’t ask me what it means just follow along. I’m going to try this myself in another day or so.

Use ALSA for KDE sounds

Building on my last post on Linux sound hacks I’m including this little gem. It’s a little bash script I wrote that plays an input parameter through ALSA. If you disable the KDE sound system you can use this shell script to push system sounds through ALSA. It assumes aplay, oggdec, and mpg321 are installed on your system. (I don’t remember their respective packages but you can use Synaptic to find them.) Here’s the code:


case $1 in

   *.ogg) oggdec -Q -o - "$1" | aplay -q &
   *.wav|*.voc|*.wav|*.au|*.raw) aplay -q $1 &
   *.mp3) mpg321 -o alsa $1 &
   *) echo "unsupported file type $1"

To use it you have to save it somewhere on your system and make it executable. (I put mine in $HOME/bin and madify my environment so that $HOME/bin is in my $PATH. Use chmod +x on the command line to make it executable.) Next go into your “System Notification” settings dialog in KDE. In the lower right corner there is a player settings button. Key in the path to the file that you saved, hit apply, then hit ok and you’re all set. If you want you can easily compare the sound that the script gives you with the sound that the KDE sound system gives you (using the player settings dialog) to hear the difference.

In my experience the KDE sound system plays sound choppy and not as high quality as ALSA. I’ve also had far too many other issues when the Sound system was running than I care to explain. Try my hack and tell me what you think.