Archive for October, 2011

October 28th, 2011  Posted at   Java, Languages
,    |   No Comments

When we pack all our java classes, libraries and resources in a single .jar in order to share our application, if our code has references to resources using absolute or relative paths to the files in our working directory like for example:

ImageIcon image = new ImageIcon('/gui/images/logo.png');

We won’t be able to get this resource when executing our standalone .jar file. We’ll have to use the getResource() method from the class. Imagine that we are using Swing for creating a cool GUI for our application. Now we want to view our custom logo in our JFrame class instead the default one. And, of course, we want this to be working even when we distribute our app in a single .jar package. If our logo were located at /src/gui/images/logo.png,  this is the code that we’ll be using for our purpose inside the JFrame class:

private void customize()
{
    try
        {
            URL res = getClass().getResource("/gui/images/logo.png");
            ImageIcon image = new ImageIcon(res);
            setIconImage(image.getImage());
        }
        catch (Exception ex)
        {
            System.err.println(ex);
        }
}

The same way for any other resources like files or music :).

Enjoy.

October 22nd, 2011  Posted at   Backtrack, Linux

I like to use an old laptop in which I’ve installed BT5. From being an useless thing inside a closet it has become a wonderful tool for me nowadays. Although I’ve a neat Alpha AWUS036H card,  it was reasonable that I wanted that its internal ipw2200bg card worked too. That is something that doesn’t happen when you run BT5 with its default configuration.

If we run dmesg we’ll see that our internal card is detected but something is happening with its firmware.

ipw2200: Detected Intel PRO/Wireless 2200BG Network Connection
ipw2200: ipw2200-bss.fw request_firmware failed: Reason -2
ipw2200: Unable to load firmware: -2
ipw2200: failed to register network device

To solve this issue we have to download the latest firmware for the card. You can get it from the official site http://ipw2200.sourceforge.net/firmware.php. I’ve uploaded the latest version at present, 3.1, so you can get it directly from here: ipw2200-fw-3.1.tgz

Once you get it extract the firmware files:

tar xvfz ipw2200-fw-3.1.tgz

Copy the .fw files to /lib/firmware:

cp ipw2200-fw-3.1/*.fw /lib/firmware/

Reset the driver:

modprobe -r ipw2200

modprobe ipw2200

Done.

Enjoy.

October 16th, 2011  Posted at   Backtrack, Linux

Post edited on Apr 28, 2013:

I’ve found a much better solution for use Chromium in BT5 but I think it’s fair to keep the original one for the record at the end of the post. So the following lines explain the new and much simpler solution:

Install the package as usual:

apt-get install chromium-browser

And now the only thing we have to do is to change the way this program is launched from the menu. So go to System >> Preferences >> Main Menu , find the “Chromium Web Browser” inside the “Internet” menu and click on “Properties”. You should see the following:

Chromium1

Change the original command “/usr/bin/chromium-browser %U” for this one:

/usr/bin/chromium-browser %U –user-data-dir

chromium2

 

Close  and we’re done.

Enjoy :)

—————————-

Original post:

For those like me that love this lightweight browser :)

When you install chromium-browser using apt from current backtrack repositories and you try to launch it, that’s what happens:

Chromium root error
 Pretty clear, isn’t it? It can’t be run as root, and that’s our Backtrack’s user!

One solution I found to be able to use chromium is to download some older version that allows us to run it as root. You can get it from the link below.

chrome32.tar.gz

Once downloaded you should do the following:

Uninstall your current chromium version (if you haven’t already done this):

apt-get remove chromium-browser

Decompress and extract the packages:

tar xvfz chrome32.tar.gz

Run installation script (it just launch apt in a proper way to resolve dependencies):

./chrome_install.sh

And that’s it, now you can enjoy this browser!

One last thing which is very important is to tell the system not to update this packages whenever we update or upgrade our Backtrack because, if we don’t do this, we’ll lose our chromium if we accept the update.

The way I like to do this:

echo “package_name hold” | dpkg –set-selections

The way to undo this:

echo “package_name install” | dpkg –set-selections

In our chromium case we have four packages that we want hold, so we have four lines to execute:

echo “chromium-browser hold” | dpkg –set-selections

echo “chromium-browser-inspector hold” | dpkg –set-selections

echo “chromium-browser-l10n hold” | dpkg –set-selections

echo “chromium-codecs-ffmpeg hold” | dpkg –set-selections

And now we’re done.

Enjoy.