Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36604
| From | parmenides <xparmenides@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | How to compile source files encoding in utf-8 with eclipse? |
| Date | 2017-05-12 18:58 +0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <of44h5$1sgk$1@gioia.aioe.org> (permalink) |
Hi all,
I am developing a tiny JSP app, and encounter a strange problem. I use
Eclipse as IDE and want to use utf-8 to encode everything such as source
files, JSP pages and class files. There are serveral settings I have done:
1. Windows > Preference > General > Workspace > Text file encoding > utf-8.
2. Windows > Preference > General > Content Types > Text > Java Source
File > utf-8.
3. Windows > Preference > General > Content Types > Java Class File > utf-8.
Then, I restarted Eclipse.
The server is Tomcat 9.0. A Servlet is created with its doGet() code:
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("****");
}
ps. * represents a chinese character.
When runinng on the server (starting from Eclipse), there some '?' on
the page. I think there are some troubles about encoding. Then, I
recompiled the source file on the command line with the following command:
javac -encoding utf-8 filename -classpath ...
and copied the generated class file into tomcat's app directory. The
page display the chniese characters normally. I think the difference is
at the encoding of class file. I can change that by command line with
-encoding option, but how to do that with Eclipse? Or there something I
have not been aware of.
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
How to compile source files encoding in utf-8 with eclipse? parmenides <xparmenides@yahoo.com> - 2017-05-12 18:58 +0800 Re: How to compile source files encoding in utf-8 with eclipse? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2017-05-12 15:04 +0200
csiph-web