protected Hyphen(final String libDir) throws UnsatisfiedLinkError,
			UnsupportedOperationException {

		libFile = libDir != null ? libDir + "/" + libName() : libNameBare();
		try {
			hunspellLibrary = (HyphenLibrary) Native.loadLibrary(libFile,
					HyphenLibrary.class);
		} catch (UnsatisfiedLinkError urgh) {

			// Oh dear, the library was not found in the file system, let's try
			// the
			// classpath
			libFile = libName();
			InputStream is = Hyphen.class.getResourceAsStream("/" + libFile);
			if (is == null) {
				throw new UnsatisfiedLinkError("Can't find " + libFile
						+ " in the filesystem nor in the classpath\n" + urgh);
			}

			// Extract the library from the classpath into a temp file.
			File lib;
			FileOutputStream fos = null;
			try {
				lib = File.createTempFile("jna", "." + libFile);
				lib.deleteOnExit();
				fos = new FileOutputStream(lib);
				int count;
				byte[] buf = new byte[1024];
				while ((count = is.read(buf, 0, buf.length)) > 0) {
					fos.write(buf, 0, count);
				}

			} catch (IOException e) {
				throw new Error("Failed to create temporary file for "
						+ libFile, e);
			} finally {
				try {
					is.close();
				} catch (IOException e) {
				}
				if (fos != null) {
					try {
						fos.close();
					} catch (IOException e) {
					}
				}
			}
			System.out.println("Loading temp lib: " + lib.getAbsolutePath());
			hunspellLibrary = (HyphenLibrary) Native.loadLibrary(
					lib.getAbsolutePath(), HyphenLibrary.class);
		}
	}