Stopping on breakpoint can cause X window system to freeze

I was experiencing this problem when debugging a Java Swing app on my Ubuntu system. When by debugger hit a breakpoint, sometimes the whole X window system would freeze. My only option was to drop to the console (ctrl-alt-f1) and kill the java process. This fix seems to have fixed it:

Add the java VM options:

for more details see this

Java Application Installers

I have a Java Swing app that I am preparing for general release and have been looking for a package and install solution. Specifically, I am looking for:

  • Package my jar file into a installer exe that will create a shortcut on the desktop
  • Installation of Java if needed or even better installer package comes with embedded JRE so no separate Java install is needed
  • Cross-platform installer would be nice but Windows users are first priority
  • Low/No Cost

There are several options out there, but my favorite so far is Packr. Packr is an open-source java packager developed by the guys at libGDX. Basically, with a quick command line, you can package your jar into a native executable for windows, mac, and linux. Whats nice is this solution embeds any JRE that you choose. Big thanks to the libGDX guys!

Android WiFi Debugging

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

And you can disable it and return ADB to listening on USB with

From a computer, if you have USB access already

It is even easier to switch to using Wi-Fi, if you already have USB. From a command line on the computer that has the device connected via USB, issue the commands

Be sure to replace 192.168.0.101 with the IP address that is actually assigned to your device.

Photo Collage Layout Algorithm

I’ve been thinking about writing an Android app that lets you view the photos on your phone in a new and different way. The idea is to cluster together images that are taken in close proximity to each other by time and location. I noticed from my own experience that I usually take pictures in sessions and each photo in the session is usually taken within 15 minutes.

So I have the general idea for how to cluster together my photos, now I need an interesting image layout algorithm. I stumbled upon a paper published by HP that outlines what they call the BRIC (Block Recursive Image Composition) algorithm. Check out section 4 for more details.

I wrote my own implementation of the BRIC algorithm in an Android app. Here are a few screenshots. I think it works pretty well.

Fix Debugging GDB Symbols

I was doing some C++ debugging on Ubuntu and noticed to find that non of the local symbols were being displayed in GDB. The only symbol available was std::__ioinit. After some digging I found the solution was to add -gdwarf-2 to the compiler command line:

Turns out this is because GCC 4.8+ now generates DWARF4 debugging symbols whereas older version of GCC generated DWARF2 symbols. The problem was my older version of GDB did not know how to use the newer DWARF format.

As noted in GCC 4.8 Release Notes:

DWARF4 is now the default when generating DWARF debug information. When -g is used on a platform that uses DWARF debugging information, GCC will now default to -gdwarf-4 -fno-debug-types-section.
GDB 7.5, Valgrind 3.8.0 and elfutils 0.154 debug information consumers support DWARF4 by default. Before GCC 4.8 the default version used was DWARF2. To make GCC 4.8 generate an older DWARF version use -g together with -gdwarf-2 or -gdwarf-3. The default for Darwin and VxWorks is still -gdwarf-2 -gstrict-dwarf.

Enable running 32-bit programs on Ubuntu 64

Recently I installed a fresh version of Ubuntu on my 64-bit machine and got errors when running 32-bit programs. I found the solution was to install the 32-bit version libs.

Error:

Solution:

MiniWeb

MiniWeb is a Http server library written in Java targeted for embedded projects. MiniWeb’s goals are to be small and lightweight as possible while providing simple and easy to use API. MiniWeb uses the very mature and robust Apache HttpComponents at its core. MiniWeb only supports what is necessary to get an embedded web project up and running quickly (no servlets).

Checkout the MiniWeb GitHub page

Example Usage

Create a server that serves files from “public” folder:

Controllers

Handle request programmatically is very simple with Controllers. The following example will respond the a request for /cgi/hello with the text world.

Query params

Controllers can even handle URL query params. For example:

Sending a /cgi/hello?param1=cool&bananas=5 and the value of param1Value would be “cool” and numBananas would be 5 as expected.

You can also use parts of the url path as parameters like so:

JSON REST Requests

Controllers can also be used to handle REST requests without all the overhead of parsing JSON manually. For example:

performing a POST to this endpoint with json: { "name": "awesome!" }. Note: the request must have a Content-Header header value set to application/json.

JSON REST Response

sending a response with JSON is also easy. Just add the @Body annotation to your handle methods.