Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java literal string: wrong charset at runtime

I am having a charset problem with literal string in Java.

As you can see at image below, I have a static object called TITULO with a literal string constant parameter "Título". When I run the program, this String is readed as "Tí-tulo". I don't know why.

Eclipse Debug View

I explore the charset settings at Eclipse Project Properties Window and Tomcat settings but all them are with UTF-8 as a option.

I'm running Tomcat 7, Eclipse Helios and Windows SO.

Can anyone help me with this issue?

like image 354
Sergio Marcelo C Figueiredo Avatar asked Oct 15 '12 23:10

Sergio Marcelo C Figueiredo


2 Answers

You might try setting the Tomcat URIEncoding to UTF-8 in the server.xml

<Connector port="8090" URIEncoding="UTF-8"/>
like image 58
Zagrev Avatar answered Nov 02 '22 05:11

Zagrev


The code that is in eclipse editor is not the same of the code that tomcat is executing.

I found a .war file at /target folder. I deleted this war file and works! The tomcat was running the classes from this old war file.

I have recently converted this running eclipse project to a maven project. I may have executed 'mvn package' at this process that created this war file.

Thanks all for help me found this solution.

like image 32
Sergio Marcelo C Figueiredo Avatar answered Nov 02 '22 03:11

Sergio Marcelo C Figueiredo