19 November, 2008

Maven repository through socks proxy

There is the solution how to access remote maven repository through socks proxy.

Just put this string:

set MAVEN_OPTS=-DsocksProxyHost=yourSocksProxyHost -DsocksProxyPort=yourSocksProxyPort

to the beginning of the "apache-maven-2.x.x\bin\mvn.bat" file.

08 November, 2008

Core icons

New project: Core icons - evolution of Eclipse icons

24 October, 2008

Eclipse icons

Now pictures from Eclipse are available at my Eclipse icons page:

I've created it in few steps:

  1. Downloaded and unzipped eclipse

  2. Extracted all images from eclipse directories, subdirectories, zips and jars*

  3. Filtered only unique files*

  4. Sorted images by dimension (16x16, 24x24, 32x32, etc.)*

  5. Removed large images (that not look like icon)

  6. Created html pages (via PHP script)

* Via my shell scripts.

This is one script from this project:


#Find and copy only unique files (with same size and checksums) from $SOURCE directory to $OUTPUT.


rm -rf $OUTPUT
mkdir -p $OUTPUT

uniqProcess() {

echo >xqx_unique.idx
while read; do
echo -ne \\r$REPLY
echo $REPLY $(stat -c%s $REPLY)+$(md5sum $REPLY|cut -f 1 -d ' ')+$(cksum $REPLY|cut -f 1 -d ' ')>>xqx_unique.idx
sort -k 2 xqx_unique.idx|uniq -f 1|cut -f 1 -d ' '|xargs -I '{}' cp '{}' $OUTPUT

find $SOURCE -type f |uniqProcess

17 October, 2008


One more mine project: emc - remote file navigator.

It developed on:
  • Client side - Flex
  • Server side - PHP
  • RPC container - XML

This is just beta version.

It is possible to release complete version (add new functionality or implement another Server side, for example). And I'm looking for the people, who want to use this in their commercial projects.
If you are interested in it, write me.

09 October, 2008

MD5 online decryption service

Last week I released new online service: MD5 Online.

It provides online encryption and decryption functionality of MD5 hashes.

20 September, 2008

Flex - autoscrolable text area

Need TextArea with automatic scrolling to bottom?
This is not trivial, but simple:

package emc.components {
import mx.controls.TextArea;

public class AutoScrollableTextArea extends TextArea {
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
super.updateDisplayList(unscaledWidth, unscaledHeight);
verticalScrollPosition = textField.numLines;

For example, it is useful for outputting log information.

18 September, 2008

PHP - roots list

Unfortunately, I don't know another way how to resolve all roots (drives) under Windows:
public function getRoots() {
$roots = array();
for ($i='A'; $i<'Z'; $i++) {
if (is_dir($disk) && is_readable($disk))
$roots[] = $disk;
return $roots;

Somebody know?

Namespaces for custom Flex components

Flex (MXML) allow to declare custom components via xmlns declaration.
Like this:
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml"

This way is useful when amount of custom components not too much and all components are located in the one or two packages.

But what about real namespaces like in Flex itself ("xmlns:mx="http://www.adobe.com/2006/mxml"); for huge amount of components?

It is possible to consolidate declaration of all components in the single file.
Like this:

<?xml version="1.0"?>

<component id="Navigator" class="emc.components.navigator.Navigator"/>
<component id="Editor" class="emc.components.editor.Editor"/>
<component id="Console" class="emc.components.console.Console"/>
<component id="SmartTruncableLabel" class="emc.components.SmartTruncableLabel"/>
<component id="AutoScrollableTextArea" class="emc.components.AutoScrollableTextArea"/>
put this file into the project sources directory and add this argument to the MXML compiler:
and then use this components in the MXML files via this declaration:
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml"
and insert component into your application:
<emc:SmartTruncableLabel id="titleLabel" styleName="filePanelTitleLabel" width="100%" />

How do you like it?

Simple URL rewrite rule for Apache

These strings in the ".htaccess" file redirect HTTP query from "worker.xml" file to "worker.php":
RewriteEngine on
RewriteBase /worker
RewriteRule worker.xml worker.php

So, it is possible to create XML (or another) facade around PHP (or another) server-side implementation.

Enable Flex trace logging

Just create "C:\Documents and Settings\{UserName}\mm.cfg" file
with this content:
and you will see Flex trace output in the "C:\Documents and Settings\{UserName}\Application Data\Macromedia\Flash Player\Logs\" directory.

PHP - exec output

This is the simple way how to capture exec output:

function execOutput($command) {
$output = array($command);
exec($command.' 2>&1', $output);
return implode("\n", $output);

echo execOutput('help');

01 September, 2008

Access logging under Tomcat

Do you want to get "access.log" file under Apache Tomcat Server as well as under Apache HTTP Server? Like this: - - [25/Aug/2008:15:08:11 +0400] "GET / HTTP/1.1" 200 82777 - - [25/Aug/2008:15:08:11 +0400] "GET /js/event-debug.js HTTP/1.1" 200 88582 - - [25/Aug/2008:15:08:11 +0400] "GET /js/history-debug.js HTTP/1.1" 200 28540 - - [25/Aug/2008:15:08:11 +0400] "GET /js/prototype.js HTTP/1.1" 200 126120 - - [25/Aug/2008:15:08:11 +0400] "GET /js/json2.js HTTP/1.1" 200 9490 - - [25/Aug/2008:15:08:12 +0400] "GET /css/app.css HTTP/1.1" 200 1937

Just insert one line into the "Engine" section of the "server.xml" file:
<Engine name="Catalina" defaultHost="localhost">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access." suffix=".log" pattern="common"/>

Also it is possible to collect and filter the set of raised files via this script:


cat access.log | cut -f2 -d"\"" access.log | cut -f2 -d" " | egrep -v -f ignore.txt | sort

//Any other patterns

HowTo run IntelliJ IDEA from the RAM-Drive under Linux

Sometimes people need to run IntelliJ IDEA at "readonly" systems.
"Readonly" I mean - without unpacking IDEA into the local file system.

These scripts will help extract and start IDEA from the RAM-Drive and remove it after using:


export JDK_HOME=/usr/lib/jvm/java-6-sun
export REQUIRED_JVM_ARGS="-Didea.system.path=$IDEA_HOME/system -Didea.config.path=$IDEA_HOME/config"

mkdir $IDEA_HOME

sudo mount -t ramfs none $IDEA_HOME
tar -xz --strip 1 --file $IDEA_TAR_GZ -C $IDEA_HOME





sudo umount $IDEA_HOME
rm -rf $IDEA_HOME

Of course you should buy IntelliJ IDEA license, get open source license or... use evaluation version.

22 August, 2008

HowTo find inconsistency between image format and file extension

Sometimes image files have inconsistency between format and extension.
For example: .jpeg file saved as .png file.

I wrote simple script in order to find such files:

process() {
while read; do
diff=`identify -format "%m %e" "$REPLY" | tr [A-Z] [a-z] | egrep -v "^(png png|gif gif|jpg jpg|jpeg jpg|jpeg jpeg)"`
test -n "$diff" && echo $diff $REPLY

find -type f -iregex ".*\.\(png\|gif\|jpg\|jpeg\)$" | process

It outputs information about real file format, file extension and filename in case of
difference between format and extension.
Like this:

jpeg png images/rating_0.png
png gif images/left.gif
gif png images/border_tr.png

11 July, 2008

Sources of com.sun.net.httpserver.HttpServer

Sun JRE contains implementation of simple HTTP server.
(in the com.sun.net.httpserver and sun.net.httpserver packages)

But this "HttpServer":

  • Not a part of Java API.

  • It is Sun's proprietary component

  • It works only under Sun JRE >=1.6

  • His sources are available only as a part of Standard Edition Development Kit Source Release under Java Research License
    (see Java™ Platform, Standard Edition 6u3 Source Snapshot Releases jdk-6u3-fcs-src-b05-jrl-24_sep_2007)

But sometimes this implementation is pretty useful (for example here).

24 June, 2008

String from base64 string, to base64 string in Java

This is very simple:

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;


public static String fromBase64(String in) throws IOException {
return new String(new BASE64Decoder().decodeBuffer(in));

public static String toBase64(String in) {
return new String(new BASE64Encoder().encodeBuffer(in.getBytes()));


Sometimes I use this latin text as dummy content in my projects:

"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed felis. Suspendisse vestibulum elit et sapien. Phasellus massa. Nam molestie placerat orci. In eu purus in eros eleifend luctus. Phasellus pede lacus, cursus nec, sollicitudin quis, vehicula in, metus. Vestibulum justo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse justo erat, eleifend ut, tempor quis, placerat vitae, justo. Vestibulum varius, libero et hendrerit pharetra, risus felis dapibus nibh, ac varius tortor odio vel quam. Morbi at velit ac purus pretium ornare. Suspendisse at nibh id purus interdum cursus. Donec feugiat egestas sem. Aenean nisl. Aliquam erat volutpat. Vestibulum et magna. Sed lacinia odio vel pede. Ut eleifend, ante vestibulum suscipit sagittis, pede lorem mollis dolor, eget pulvinar tortor libero eu mauris.

Donec sollicitudin sollicitudin leo. Aenean diam dolor, semper sit amet, malesuada quis, sodales sed, nulla. Nunc aliquam purus vitae est. Pellentesque ut est at sem imperdiet consectetuer. In eros. Nullam pulvinar. Sed risus urna, pharetra ornare, gravida nec, venenatis quis, nisl. Nullam euismod mauris. Praesent ut ipsum quis augue faucibus malesuada. Proin dui mauris, condimentum sit amet, ultricies non, interdum eget, mi.

In rutrum, neque et consectetuer semper, dolor ligula rhoncus lectus, eu egestas nunc quam ut est. Morbi quis turpis adipiscing dui pharetra commodo. Nullam pulvinar nibh non lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi blandit arcu ac urna. Suspendisse felis erat, gravida sed, pulvinar sed, ullamcorper in, purus. Mauris libero. Donec eros neque, tempus a, malesuada sed, ullamcorper a, leo. Pellentesque cursus, sem a pretium porta, mi magna faucibus mauris, sit amet porta quam pede vitae neque. In fermentum, neque et volutpat euismod, arcu libero luctus est, in euismod augue est porttitor mauris. Vivamus a lorem sit amet erat tempus convallis. Integer malesuada odio vitae libero. Proin aliquam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nunc sodales. Praesent at sem ac purus commodo faucibus. Nam ultricies neque ultrices tortor molestie cursus. Phasellus eget lectus. Maecenas semper dolor et turpis.

Nam iaculis, pede sit amet nonummy dignissim, nulla tellus condimentum mi, vitae mattis mi felis in mi. Mauris et nulla at tellus porttitor posuere. Duis erat ante, bibendum ut, pulvinar in, adipiscing ac, nunc. Sed volutpat augue ac pede. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Suspendisse potenti. Curabitur lectus. Suspendisse ultrices, arcu sed condimentum congue, leo elit aliquam risus, et interdum leo erat sit amet ante. Aliquam ac tellus. Proin ut felis. Curabitur volutpat sagittis lacus. Pellentesque tempus tincidunt pede.

Duis leo metus, consectetuer ac, posuere id, iaculis quis, massa. Curabitur pellentesque, pede sit amet pellentesque feugiat, odio justo condimentum eros, non mollis augue ante at ipsum. Nunc iaculis eros eu nibh. Nunc ligula sem, semper id, fringilla et, mollis a, ante. Maecenas viverra nibh sit amet nunc. Aenean rhoncus ante ut nibh. Duis hendrerit lorem sed enim. Donec et velit vitae leo rutrum faucibus. Donec mi. Proin laoreet, tellus at placerat nonummy, erat tellus lobortis metus, luctus sagittis enim urna sit amet odio. Praesent vitae ligula quis velit sagittis iaculis.

Aliquam consequat justo. Nulla facilisi. Mauris eget magna. Donec hendrerit imperdiet libero. Aliquam tincidunt libero sit amet diam suscipit auctor. Phasellus sit amet risus et pede mollis faucibus. Nunc nec purus quis augue pulvinar commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Ut porttitor vestibulum lacus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas congue.

In hac habitasse platea dictumst. Vestibulum vestibulum facilisis neque. Nunc id elit ut orci volutpat convallis. Vivamus vel urna. Etiam auctor. Pellentesque suscipit eros sit amet purus. Proin cursus dolor id felis. Donec venenatis, nisl sit amet consequat condimentum, tortor leo faucibus risus, ut fermentum ipsum felis nec nibh. Suspendisse mattis adipiscing felis. Maecenas eu magna. Nulla eros odio, nonummy nec, volutpat ut, auctor ac, lacus. Sed nec est. Donec libero est, auctor eu, molestie eu, lacinia ut, elit. Suspendisse quis orci."

18 June, 2008

HowTo override and substitute document.write function in JavaScript (sample)

It is pretty simple to wrap document.write function in JavaScript.

For example - using closures:
<script id="source" type="text/javascript">
function wrapString(str) {
return "(" + str + ")";

document.write = function(w) {
return function(s) {
w.call(this, wrapString(s));


This "advanced piece of engineering" prints string: (Hello)(world)

How do you like it?

15 June, 2008

HowTo batch remove temporaty files from directory and subdirectories

Just create .bat file with this content:

@set path=
@for /R %%i in (*.tmp *.bak) do @del %%i

and update (*.tmp *.bak) section with your set of files or masks.

27 April, 2008

HowTo simulate Googlebot

Googlebot is Google's web crawling robot, which finds and retrieves pages on the web and hands them off to the Google indexer.
Googlebot visits sites with special value in his HTTP request header.

It uses special user-agent string:
"Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)"

It is possible to simulate Googlebot from the shell script via wget program.

Like this:



FIREFOX_USERAGENT_STRING="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080404 Firefox/"
GOOGLEBOT_USERAGENT_STRING="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

#get page for firefox browser
wget -c --user-agent="$FIREFOX_USERAGENT_STRING" --output-document=firefox.html "$TEST_URL"

#get page for google bot
wget -c --user-agent="$GOOGLEBOT_USERAGENT_STRING" --output-document=googlebot.html "$TEST_URL"

This script may be useful for testing of site's search engine optimization.

...May the Force be with you...

28 February, 2008

Xml elements and attributes in the ExtJS table

Ext JS - JavaScript Library is pretty powerful JavaScript/AJAX framework for building of Rich Internet Applications.

I've used it in my last public web project: Ubuntu index.

ExtJS has set of useful UI controls, internal components and strong AJAX, XML and JSON support.

E.g. you can present this XML file:


<?xml version="1.0"?>


<item id="alien-arena">
<name>Alien Arena</name>

<item id="nexuiz">

<item id="openarena">


as a table via this HTML + JavaScript code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<title>ExtJS Table Sample</title>
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"/>
<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>

<script type="text/javascript">
Ext.onReady(function() {
var reader = new Ext.data.XmlReader({record: "item"},
[{name: "id", mapping:"@id"}, "name"]);

var store = new Ext.data.Store({url: "items.xml", reader: reader});

var columnModel = new Ext.grid.ColumnModel([
{header: "Id", dataIndex: "id"},
{header: "Name", dataIndex: "name"}]);

var table = new Ext.grid.GridPanel({
store: store,
height: 200,
cm: columnModel,
renderTo: "table"

<div id="table" style="width:300px; height:200px;"></div>

Here is the browser's view:

22 January, 2008

Linux reference

I found really useful documentation for Linux beginners.

"This Debian Reference (http://qref.sourceforge.net/) is intended to provide a broad overview of the Debian system as a post-installation user’s guide. It covers many aspects of system administration through shell-command examples. Basic tutorials, tips, and other information are provided for topics including fundamental concepts of the Debian system, system installation hints, Debian package management, the Linux kernel under Debian, system tuning, building a gateway, text editors, CVS, programming, and GnuPG for non-developers."

This book is devoted to Debian system but it is topical for some other Linux systems.

StarCraft (Brood War) under Linux (Wine)

I use this script to play network StarCraft under wine:


#At first, run "wine setup.exe"


ipx_interface add -p eth0 802.2 0x39ab0222
xinit /usr/bin/wine starcraft.exe

I think it is the best game.

Flash-light from console

With this script I use my monitor as flash-light in the darkness.


#Switch monitor (CRT or LCD) to flash-light mode.

echo -e "\\033[47;30m"
echo -e "\\033[0m"

16 January, 2008

Java processes viewer

There is a way how to retrieve information about all running JVMs.
Since Java 1.5 Sun provides sources of jvmstat classes for JVM monitoring.

I've created simple program that is used these classes.
It detects all running JVMs and prints their information.


import java.util.Set;
import sun.jvmstat.monitor.HostIdentifier;
import sun.jvmstat.monitor.MonitoredHost;
import sun.jvmstat.monitor.MonitoredVm;
import sun.jvmstat.monitor.StringMonitor;
import sun.jvmstat.monitor.VmIdentifier;

public class JavaPS {
private static final String[] vmProperties = new String[]{

public static void main(String[] args) {
Set jvms;
MonitoredHost monitoredHost;

try {
monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier("localhost"));
jvms = monitoredHost.activeVms();
} catch (Exception e) {

for (Object jvm : jvms) {
int jvmid = (Integer) jvm;
System.out.println("Process ID: \t" + String.valueOf(jvmid));
try {
VmIdentifier id = new VmIdentifier("//" + jvmid + "?mode=r");
MonitoredVm vm = monitoredHost.getMonitoredVm(id, 0);
for (String vmProperty : vmProperties) {
System.out.println(vmProperty + ": \t"
+ ((StringMonitor) vm.findByName(vmProperty)).stringValue());
} catch (Exception e) {

Aliases for virtual machine's properties have been taken from jdk1.5 sources (jdk-1_5_0-src-scsl.zip) from the file j2se\src\share\classes\sun\jvmstat\perfdata\resources\aliasmap.

Compile this code via command:
javac -classpath %JAVA_HOME%\lib\tools.jar JavaPS.java
and run:
java -classpath .;%JAVA_HOME%\lib\tools.jar JavaPS >JavaPS.txt

jvmstat package locates in tools.jar

Example of results output:


Process ID: 2144
java.property.java.vm.name: Java HotSpot(TM) Client VM
java.property.java.vm.vendor: Sun Microsystems Inc.
java.property.java.vm.version: 1.6.0_03-b05
java.property.java.home: C:\Program Files\Java\jre1.6.0_03
java.property.java.class.path: .;E:\Devel\jdk1.5.0_09\lib\tools.jar
sun.rt.javaCommand: JavaPS

Process ID: 364
java.property.java.vm.name: Java HotSpot(TM) Client VM
java.property.java.vm.vendor: Sun Microsystems Inc.
java.property.java.vm.version: 1.6.0_03-b05
java.property.java.home: C:\Program Files\Java\jre1.6.0_03
java.property.java.class.path: SwingSet2.jar
sun.rt.javaCommand: SwingSet2.jar

Simple RTF to XML converter

RTFEditorKit (javax.swing.text.rtf.RTFEditorKit) from Sun Java API - special class for operations with RTF (Rich Text Format) documents.

I've created java sample that converts RTF document to XML.



This is the source of this converter:


import javax.swing.text.AbstractDocument.BranchElement;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.BadLocationException;
import javax.swing.text.rtf.RTFEditorKit;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;

public class Rtf2XML {
private DefaultStyledDocument rtfSource;
private org.w3c.dom.Document xmlTarget;
private org.w3c.dom.Element xmlRoot;

private void expandElement(javax.swing.text.Element rtfElement) {
for (int i = 0; i < rtfElement.getElementCount(); i++) {
javax.swing.text.Element rtfNextElement = rtfElement.getElement(i);
if (rtfNextElement.isLeaf()) {
try {
} catch (Exception e) {
} else {

private void addElement(javax.swing.text.Element rtfElement)
throws UnsupportedEncodingException, BadLocationException {

String style = new String(rtfSource.getLogicalStyle(rtfElement.getStartOffset())

String text = new String(rtfSource.getText(rtfElement.getStartOffset(),
rtfElement.getEndOffset() - rtfElement.getStartOffset())

org.w3c.dom.Element node = xmlTarget.createElement("p");
node.setAttribute("style", style);

public void convert(String sourceFileName) throws Exception {
rtfSource = new DefaultStyledDocument();
RTFEditorKit kit = new RTFEditorKit();
kit.read(new FileInputStream(sourceFileName), rtfSource, 0);

xmlTarget = DocumentBuilderFactory.newInstance()

BranchElement rtfRoot = (BranchElement) rtfSource.getDefaultRootElement();
xmlRoot = xmlTarget.createElement("data");

Transformer t = TransformerFactory.newInstance().newTransformer();
t.transform(new DOMSource(xmlTarget),
new StreamResult(new FileOutputStream(sourceFileName + ".xml")));

public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: *.rtf");
try {
new Rtf2XML().convert(args[0]);
} catch (Exception e) {

But RTFEditorKit isn't so powerful and friendly as I want.
I think, iText will be better for operations with RTF (and other document formats).

It's the good and free decision.

10 January, 2008

Simple Java MIDI synthesizer sample

Another multi-media sample - simplest Java MIDI synthesizer.


import javax.sound.midi.*;
public class MidiSynthesizerSample {
  public static void main(String[] args) {
      int[] notes = new int[]{60, 62, 64, 65, 67, 69, 71, 72, 72, 71, 69, 67, 65, 64, 62, 60};
      try {
          Synthesizer synthesizer = MidiSystem.getSynthesizer();
          MidiChannel channel = synthesizer.getChannels()[0];
          for (int note : notes) {
              channel.noteOn(note, 50);
              try {
              } catch (InterruptedException e) {
              } finally {
      } catch (MidiUnavailableException e) {

See example of Java MIDI application:

09 January, 2008

Simple Java MIDI player sample

New Year!

- is a musical project. It is a bayan keyboard emulator, Java MIDI application for personal computers.
Now everybody can play bayan (button accordion).

XenoHarmonica is free for education and non-commercial usage.

Program based on Java MIDI API.
In this article I provide an example of simplest MIDI player.

Maybe somebody else going to create MIDI program :-)

package xantorohara.xenoharmonica.samples;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import java.io.FileInputStream;
public class MidiPlayerSample {
    public static void main(String[] args) {
        try {
            Sequencer sequencer = MidiSystem.getSequencer();
            if (sequencer == null)
                throw new MidiUnavailableException();
            FileInputStream is = new FileInputStream("sample.mid");
            Sequence mySeq = MidiSystem.getSequence(is);
        } catch (Exception e) {

Windows XP hibernate mode problem

Do you have a problem with Hibernate mode in Windows XP?
And you can't turn on Hibernate mode from Power Options Panel, it says: "The process cannot access the file because it is being used by another process".
I found one crasy method how to resolve this problem on my computer (AMD64/1G RAM/MB Asus M2NE/Video Asus N7600/IDE HDD).

  • Delete file: WINDOWS\system32\drivers\atapi.sys (it will be restored by Windows).

  • Manualy enable hibernate mode (now it isn't throw error message).

  • Switch computer to Hibernate mode.

Is it helpful?