Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

java.lang.IllegalArgumentException: Malformed \uxxxx encoding

with 11 comments

The above error is cause by the baclslash “\” that use in Windows.

I demostrate the error in this simple example.
The example is going to get the File object that being instancial by Spring to do further process.

The java code is looks like this:

public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				new String[] {
		BeanFactory factory = (BeanFactory) context;
		final String myFileBeanName = "myFile";
		File file = (File) factory.getBean(myFileBeanName);

The applicationContext.xml for Spring:

<bean id="myFile" class="">

In the properties file, the $file.path is defined as file.path=D:\data\test\my-spring-file.txt.

When I trying to run the java code, it returns me

Exception in thread "main" java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
at java.util.Properties.loadConvert(Unknown Source)
at java.util.Properties.load(Unknown Source)

So, I change the $file.path to file.path=D:\\data\\test\\my-spring-file.txt, and its work fine to me!


Written by Alfred

November 13, 2008 at 15:20

Posted in Java, Spring

Tagged with , ,

11 Responses

Subscribe to comments with RSS.

  1. Stunning, I didn’t know about this topic till now. Thanks.


    December 12, 2009 at 8:54

  2. I had the same problem,
    for me worked deleting the file c:\users\$my_user_name\.appletviewer


    April 15, 2011 at 16:31

  3. Thanks, I was looking for this information.

    Subrata Nath

    August 9, 2011 at 21:27

  4. Also, if the paths inside the properties file are in the following format
    C:\myfolde\myfile.txt, malformed encoding exception occurs. So, change the paths inside the path to C:\\myfolder\\myfile.txt


    September 1, 2011 at 23:01

  5. Thanks for the info 🙂 saved me a couple of hours…….!!!


    November 21, 2011 at 22:14

  6. thompson cigar coupon
    Thanks for this excellent post. I genuinely like the content you put up on your web page. Added to my bookmarks for future visits. thompson cigar coupon

    thompson cigar coupon

    March 29, 2012 at 7:33

  7. one direction sued
    I would like to show my appreciation to you just for bailing me out of such a condition. Because of looking out through the internet and meeting ways which were not helpful, I thought my life was gone. Being alive devoid of the strategies to one direction what makes you beautiful lyrics the difficulties you have solved through your guide is a crucial case, and ones which could have in a negative way affected my entire career if I had not noticed your blog post. Your actual natural talent and kindness in controlling every part was very helpful. I am not sure what I would’ve done if I had not encountered such a point like this. I’m able to now look forward to my future. Thanks very much for your reliable and sensible guide. I won’t hesitate to propose your web sites to anybody who would like guidelines about this problem.

    one direction book

    April 22, 2012 at 0:33

  8. Adore that your headline created me click the link in the google search. Great content material. Thanks for sharing! Steve Nash Andy Griffith

    Ray Allen

    July 10, 2012 at 4:45

  9. Thanks man , this information is really useful 🙂

    indra preet

    July 19, 2012 at 18:37

  10. Thank you very mich for this precious piece of information, very helpful ,
    I could not find anything in SAP documentation

    Raoul Shiro

    November 19, 2012 at 21:27

  11. Thanks!

    Raj Thapa

    March 15, 2013 at 3:06

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: