Twitter And Other Updates
Posted by gamlerhart in 42 on August 12, 2010
Good news everyone, I’m now on Twitter. This means I can spam now in 140-character chunks, hooray. The latest tweets are also visible on this blog on the right side bar.
Furthermore I’ve reorganized some small things on this site. For example I splitted nearly everything in two main categories. The Media Zap Oh Snap-category for everything media-related like TV-series, music and movies. Then there’s the ‘Technical Wibbly Wobbly‘-category for everything technical.
I’ve also updated and extended the Blogroll and Link section. (Thx @ GedankenDeponie)
That’s it for now. Next time it’s going to be a more useful post =)
Lookup Logic For Native Libraries in Java
Posted by gamlerhart in java on July 26, 2010
If you want to do something in Java, there’s certainly Java library which helps you with to achieve your goal. However, for some stuff (3D rendering, accessing I/O devices) the Java API’s are not enough and you need to interact directly with the target platform. In such cases, you need to use the Java Native Interface and provide a native library. This also means that you need to ship your application with additional native libraries. Here’s where the issues start.
When you use native-libraries, the JVM needs to load those. By default the JVM loads those libraries from a few standard system paths. Of course you don’t want to touch those. The other alternative is to specify an look-up path with the JVM-argument ‘java.library.path’. This works most of the time, but still has its issues! First, it doesn’t work with a simple jar-launcher! In order to specify this JVM-argument, you need to add a launch-script. The second issue has to with packaging your application. Imagine that you ship your application for different OS, like Linux, Windows 32- and 64-Bit etc. The native binaries are named the same, but are actually for different versions. For example there are two versions of ‘coolLibrary.dll’ one for 32-Bit, one for 64-Bit. You cannot have both in the same directory. You somehow need to decide at runtime which one you pick.
So what you want is to be more flexible how to resolve a native library. And you can! Thanks to our friend ClassLoader. Basically you can overwrite the ClassLoader.findLibrary()-method and implement you own resolving strategy. For example:
Of course, this class-loader should be the ‘root’ class loader of your application. This means this class loader should be responsible for loading all application-classes. To do this, I usually create a small ‘boot’-application, which starts the real application. Basically what it does is to instantiate the NativeLibPathClassLoader, pass it the location of the application with dependencies and then load the real application. Not that your ‘real’ application shouldn’t be on the regular class-path. Otherwise everything is loaded by the system class loader:
Source-Link for RSS
This is how I start up Java Desktop Applications which need native libraries. It works wonderful and it solves the annoying ‘java.library.path’-path issue.
Analyzing Dependencies Java
Posted by gamlerhart in java on July 20, 2010
As software developers, we use daily some nice libraries to archive our goals. Of course, the libraries authors also use libraries to get the job done. In practice libraries have a some transitive dependencies. Just take a look a Hibernate, which is brings tons of libraries.
Normally the dependencies are documented somewhere, so that you can include the right one in your project. Also tools like Maven or Ivy help to include the right bits. But what if you have downloaded a project, which brings tons of required and optimal libraries with it and you want to find out the relations-ships?
A small tool called Jar Jar Links can help. Normally this tool is used to merge different jar-files. But it can also scan through jar-files and find out the dependencies. The command for this is this: java –jar jarjar.jar find jar <list of jars>. For example I analyzed the some parts of Hibernate: java –jar jarjar.jar find jar hibernate3.jar;./lib/required. The output looks like this:
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\slf4j-api-1.5.8.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\commons-collections-3.1.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\dom4j-1.6.1.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\jta-1.1.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\javassist-3.9.0.GA.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\required\antlr-2.7.6.jar
C:\temp\hibernate\hibernate3.jar -> C:\temp\hibernate\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar
You even can list all dependencies of classes to each other, by using: java –jar jarjar.jar find class <list of jars>.
Anyway it’s a small and useful tool. Of course, it only finds dependencies which are compiled into the classes. Stuff which is loaded via reflection cannot be detected.
Doctor Who Series 5 *Spoilers*
Posted by gamlerhart in Media Zap Oh Snap on July 14, 2010
A new producer and head writer (Steven Moffat), a new Doctor (Matt Smith), a new companion (Karen Gillan) and a new shiny TARDIS-decoration. Tons of changes for the latest Doctor Who season. Let’s take a look.
The Eleventh Hour (S05E01)
There’s a crack in the wall in Amelia’s room and she’s afraid of it. Just as she ask Santa Clause for help, the Doctor appears and helps her. However he has problems to land the TARDIS at the right time. That’s why he arrives 12 years to late to help Amelia. Meanwhile Amelia has grown up and calls herself Amy. Now the Doctor and Amy try to catch a dangerous Alien prisoner which hides on earth. The timing-issues, meeting Amy at different ages combined with a quite typical Doctor Who story makes it the perfect companion-introduction.
The Beast Below (S05E02)
Amy and the Doctor land on Starship UK, a giant space-ship which contains the whole British population. The ship was build because the earth has become uninhabitable. However something is wrong with the ship. All people are afraid of the ‘Smiler’-robots, which ensure safety and order. It looks like there’s terrible secret to be discovered.
Victory of the Daleks (S05E03)
Second World war, London is under attack. Luckily the military has a new secret weapon. To the Doctors surprise this weapon are Daleks, which are friendly and help the people. But of course, the Daleks have yet another genius plan to rule the universe.
The Time of Angels (S05E04) / Flesh and Stone (S05E05)
The Doctor finds a message from River Song. He meets River and lands of a crash-site of a spaceship, which contains one of the deadliest creatures, a Weeping Angel. And of course, instead of leaving this dangerous place, the Doctor starts to wonder around and brings himself into trouble. River Song is back! The Weeping Angels are back! What else can you ask for?
Amy’s Choice (S05E07)
Rory, Amy’s fiance and the Doctor keep dreaming the same dream. Or is it really a dream? Which one is the dream and which what’s reality? In both they fear a deadly thread. But how can they find out which one is real?
The Hungry Earth (S05E08) / Cold Blood (S05E09)
As a science team drills down into the earth, they disturb a Silurian colony which is living deep down under the earth. Of course the Silurians get pissed of and some of them try to start a war against humans. Once again the Doctor helps to keep the peace.
Vincent and the Doctor (S05E10)
The Doctor discovers a monster in one of Vincent van Gogh paintings. He travels back in time to take a look himself. Unfortunately the monster is invisible and only Vincent can see it. Quite tricky to kill a monster you cannot see, especially when you have to deal additionally with a depressed painter.
The Lodger (S05E11)
The TARDIS is disturbed by a strange force, which’s origin seams to be a flat. Meanwhile people keep disappearing in the very same flat. The Doctor decides to move in to find out what’s wrong with it.
The Pandorica Opens (S05E12) / The Big Bang (S05E13)
River Song warns the Doctor that the TARDIS will explode. Additionally they find a mysterious ‘Pandorica’. The ‘Pandorica’ imprisons the deadliest thing in the universe. And it is about to open itself.
Conclusion & Opinion
This is it, season 5. In my opinion it is the ‘worst’ season so far. Not that it is bad, it’s still an extraordinary wonderful series. But it isn’t as good the previous seasons. I can’t really tell what’s the difference. So I’m not worried and I can’t wait for the Christmas special and the next season!
Exception-Handling: BeginInvoke vs ThreadPool.QueueUserWorkItem
Posted by gamlerhart in .NET, software-development on June 30, 2010
Sometimes small changes make have a large impact. An example is the exception-handling difference of Delegate.BeginInvoke and ThreadPool.QueueUserWorkItem.
I’m working on a WPF-client application, which does quite a lot of work in the background. Most of the background work is handled by a special task coordination class. For a long time this class executed tasks with ThreadPool.QueueUserWorkItem. And it worked well:
As you can imagine, a desktop application crashes sometimes. So there’s a central error-handler, which is invoked when the application crashes:
Everything worked as expected. When a background task crashed, it trigger the error-handler as expected (it triggered also the VisualStudio-debugger).
One rainy day, I improved the task coordination class. Among other changes it exchanged the the ThreadPool.QueueUserWorkItem with a Delegate.BeginInvoke.
My tests and the application worked fine with the changes for quite a while. So I continued to improve the application. After a while, I started to notice some strange behaviors. Sometimes some work just wasn’t executed. Then it notices a lot of first chance exceptions in the debugger-output. I got suspicious and started to investigate. Soon I found out that my change from ThreadPool.QueueUserWorkItem to Delegate.BeginInvoke was the issue. Some exceptions in back-ground tasks weren’t processed.
What’s the difference?
As you know, Delegate.BeginInvoke isn’t just running the code in the background. It brings synchronization-mechanisms and the Delegate.EndInvoke-operation with it. And here also starts my exception issue. When a exception happens while executing the Delegate.BeginInvoke, the exception is caught. As soon as you get the result with Delegate.EndInvoke, the caught exception is thrown. I wasn’t aware of that. And unfortunately I didn’t end all tasks with Delegate.EndInvoke!
My solution was to switch back to the ThreadPool.QueueUserWorkItem. This operation doesn’t do any fancy synchronization for you. It just executes the delegate on the ThreadPool. If something goes wrong, the exception just blows into your face. The passed delegate is responsible to handle exceptions.
For RSS feed readers: I’ve just noticed that the gist-code-examples don’t show up in the feed-view =(. Has someone an idea how to fix that? Meanwhile you need to read the post on the website.
Bachelor Thesis Finished \o/
Posted by gamlerhart in 42, projects on June 17, 2010
After four months hard work I’ve finished my bachelor thesis. Time to drink beer and relax =)
Talks and Short Movies
Posted by gamlerhart in 42, Media Zap Oh Snap on June 14, 2010
Yet another collection of interesting talks:
- First, a quite old talk about exponential growth and how we often don’t understand its implications. The talk starts quite boring with simple math. But later the presenter starts talking about the implications, how we periodically don’t use simplest math and how politics and economy ignore simple facts. Watch it, watch it, watch it!
- Dan Pink talks about the science of motivation. The sad thing is, that lots of companies/people ignore the facts and to the wrong thing to motivate people.
- A interview (part one, part two) with Corinne Yu about game-engines, 3d-graphics, programming, game-consoles etc.
Now to some wonderful short movies:
- First, I’m Here, a movie about a robot who falls in love. A half an hour of pure movie brilliance. Found on freeQnet.
- Another great short-movie: Heartless: The Story of the Tin Man, a prequel to the Wonderful Wizard of Oz story.
Opera Speed Test
Posted by gamlerhart in 42, tools on May 29, 2010
My favorite browser, Opera, is fast, extremely fast. Newest scientific methods are used to measure its speed
Ok, ok, the Chrome-guys game up first with speed test videos. Here’s the original:
Found via irrlicht3d.org, original source Opera-blog.



(4/5)















(4.5/5)