Archive for the ‘Development’ Category

Reading URLs protected with HTTP Authentication with Java

Tuesday, September 23rd, 2008

In Java, you can use URLConnection class to read from an URL. For example, to read the page from google.com, you can do something like this:

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL google = new URL("http://www.google.com/");
        URLConnection gc = google.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                gc.getInputStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}

If the access to the URL is protected with authentication mechanism, IOException is thrown when you try to read from InputStream associated with URLConnection. In that case, you need to use Authenticator class from java.net package, that makes accessing password-protected URLs as easy as can be.

(more…)

Compiling SDL_image with MSYS/MinGW

Sunday, August 13th, 2006

1. Introduction

SDL_image is an image loading library that is used with the SDL library, and almost as portable. It allows a programmer to use multiple image formats without having to code all the loading and conversion algorithms themselves. SDL_image supports BMP, GIF, JPG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM and XV image formats.

SDL_image requires JPEG library for JPG image support, PGN libarary and zlib library for PGN image format support, and the TIFF library for TIFF image support.

Note: Current version of TIFF library has some problems compiling under Windows/MinGW, so we will disable support for tif file format in SDL_image library.

(more…)

Setting up MSYS/MinGW build system for compiling SDL/OpenGL applications

Tuesday, August 8th, 2006

1. Introduction

MSYS is a Minimal SYStem to provide POSIX/Bourne configure scripts the ability to execute and create a Makefile used by make on MS Windows operating system.
MinGW is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU tool sets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.
In this tutorial we will setup MSYS/MinGW configuration, and compile libraries needed for development of SDL and OpenGL applications.

(more…)