I think i found the answer. I found this :
Comparing the output of the above code to the output of the md5sum command, the results are completely different. Why should this be?
Couple of possible reasons.
1) The default character encoding on your machine is not "CP1252"
The java program specifies this charset when getting the bytes of the message.
To figure out your default character set, you can call:
System.getProperty("file.encoding")
If you replace the "CP1252" string in the test program with the above call, it should work.
Unless...
2) You are sending md5sum a file and your file has a newline in it. The java program
is sending just the text "Hello, world!" (with no trailing characters)
Make sure there's no newline in you file by using the -n flag to echo. (there should only be 13 chars)
Indeed, i was using echo without the -n. Sorry for this
[originally posted on jforum.net by Anonymous]