Results 1 to 10 of 10

Thread: Unable to display special characters in Java

  1. #1
    Junior Member
    Join Date
    Jan 2007
    Posts
    9

    Unable to display special characters in Java

    I wrote a program that traverses a directory for files of a given extension and then displays the absolutePath in a JList. Double-clicking on a filename will open it in the registered program. It works perfectly for English filenames. The problem is when I have other characters in the filename. For example, if I have a file titled "Mexico.txt" with an accented e, it shows up in the list with a block in place of the e. So the first problem is not being able to properly display the special characters. Next, if I double-click that file it sees the absolutePath as "m%3Fxico.txt" which I'm guessing is some sort of unicode encoding. Unfortunately, that encoding is not handled properly by the Runtime.getRuntime() method. I get a "file does not exist" error. All features work fine with English characters.

    I have tried the JRE that comes with Knoppix 5.1.1 as well as fresh installs of JRE5 and JRE6 with the same results. In Windows Vista the accented characters appear properly when using JRE5 and JRE6.

    Any help with these issues is greatly appreciated.

  2. #2
    Senior Member registered user
    Join Date
    Apr 2005
    Posts
    159

    Re: Unable to display special characters in Java

    What is your locale? Type "echo $LANG" in a konsole. I am guessing you need a Unicode locale for proper international support (e.g. en_US.UTF-8). You may also need to specify the character set your filesystem uses to encode filenames (as an option is /etc/fstab).

  3. #3
    Junior Member
    Join Date
    Jan 2007
    Posts
    9
    Echo $LANG returns C
    just the single letter C

    Here's the thing. I can create files in KDE all day long with accented characters. I also added the Spanish keyboard layout so I can easily type accented characters and it works perfectly. In the terminal when I do ls in the folder with accented filenames, the accented letters appear as a "?" (M?xico, for example). But I can do cat Mexico (accented e) and it displays the contents properly.

  4. #4
    Senior Member registered user
    Join Date
    Apr 2005
    Posts
    159
    Open a konsole, then type "export LANG=en_US.UTF-8" (C is definitely ascii-only). Then retry ls, and launch your java program (from the command line so it picks up the new locale). If this helps, you may want to refine with a unicode-enabled Spanish locale. And you haven't told us what kind of FS you're looking at, if your knoppix is HD-installed and if you're using a lang=xy cheatcode...

  5. #5
    Junior Member
    Join Date
    Jan 2007
    Posts
    9
    I tried what you suggested and I know it took effect because echo $LANG returned export LANG=en_US.UTF-8
    the ls command listing still shows a ? in place of accented characters. But the actual line where I'm typing commands will display accents properly.
    I started the java app from the same command line and it still puts a block in place of accented characters. I also tried the locales en_US and es_US (Spanish, I think) with the same results.

    Next, I ran "dpkg-reconfigure locales" and selected "all locales." Same results.
    Then I ran "locale-gen." Same results.

    I did an HD install from the KNOPPIX DVD 5.1.1 with the option that makes it run live the live DVD. File system is reiserFS.

  6. #6
    Senior Member registered user
    Join Date
    Apr 2005
    Posts
    159
    I am seeing exactly all the symptoms you describe with my copy of the knoppix 5.1.0 CD running under VMWare player. My regular debian sarge install, OTOH shows filenames with accented characters without any problem (konq, xterm, ls, java...). LANG is set to en_GB (not even explicitly utf, and the FS is ext3 - but i doubt it matters. Either locale support is broken in knoppix, or the setting that would correct things escapes me, sorry...

  7. #7
    Senior Member registered user
    Join Date
    Apr 2005
    Posts
    159
    Hi "330toSRT8", I don't know if you have solved your problem but I came across this entry in the debian FAQ which might help you.

  8. #8
    Junior Member
    Join Date
    Jan 2007
    Posts
    9
    Nope, haven't solved it yet. Thanks for the link. It looks promising. I'm gonna try some of those things.

  9. #9
    Junior Member
    Join Date
    Jun 2007
    Posts
    3
    Hey 330toSRT8!

    Did you ever figure out the charset/Java/Knoppix problems? I'm having exactly the same problem; please see my post!

  10. #10
    Junior Member
    Join Date
    Jan 2007
    Posts
    9
    Quote Originally Posted by joakimk
    Hey 330toSRT8!

    Did you ever figure out the charset/Java/Knoppix problems? I'm having exactly the same problem; please see my post!
    Nope, I haven't found the answer yet.

Similar Threads

  1. Replies: 1
    Last Post: 07-07-2007, 10:45 PM
  2. (v5.0.1)Display Chinese/East Asia characters
    By lovetide in forum General Support
    Replies: 0
    Last Post: 06-07-2006, 05:23 PM
  3. emacs 21 (text) and special characters, i.e umlaute (solved)
    By lutzweber in forum Tips and Tricks
    Replies: 0
    Last Post: 03-25-2005, 10:45 PM
  4. Unable to open display properties
    By ZX in forum General Support
    Replies: 0
    Last Post: 03-15-2004, 08:34 AM
  5. Problems with non ASCII characters in Java
    By phoneutria in forum General Support
    Replies: 0
    Last Post: 08-21-2003, 08:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


OWC Mercury Elite Pro 2 Bay RAID Enclosure with USB 3.2  for Dual 3.5 inch HDDs picture

OWC Mercury Elite Pro 2 Bay RAID Enclosure with USB 3.2 for Dual 3.5 inch HDDs

$87.99



Broadcom MegaRAID 9480-8e Fujitsu PRAID EP540e SAS RAID Card (Replac 9380-8e) 8i picture

Broadcom MegaRAID 9480-8e Fujitsu PRAID EP540e SAS RAID Card (Replac 9380-8e) 8i

$228.00



Areca ARC-1882IX-24 (16i4e)24-Port RAID Controller Card w/BBU /HDD Monitor Board picture

Areca ARC-1882IX-24 (16i4e)24-Port RAID Controller Card w/BBU /HDD Monitor Board

$300.00



Broadcom 9600-24i RAID Controller PCIe Gen 4.1 Tri-Mode NEW 05-50111-01004 picture

Broadcom 9600-24i RAID Controller PCIe Gen 4.1 Tri-Mode NEW 05-50111-01004

$649.99



Dell PowerEdge HBA330 LP PCI-E 12GBs RAID SAS Controller Adapter J7TNV picture

Dell PowerEdge HBA330 LP PCI-E 12GBs RAID SAS Controller Adapter J7TNV

$18.95



Broadcom LSI 9305-16i 12Gbps SAS-3 PCIe x8 HBA 16-Ports Raid Controller picture

Broadcom LSI 9305-16i 12Gbps SAS-3 PCIe x8 HBA 16-Ports Raid Controller

$64.99



LSI 9305-16i SATA SAS 12Gbs Controller card PCIe 3.0 IT-Mode w/SAS SATA cable US picture

LSI 9305-16i SATA SAS 12Gbs Controller card PCIe 3.0 IT-Mode w/SAS SATA cable US

$125.98



NVME M.2 Adapter Card PCIE X16 Splitter Expansion Controller 4-Disk Soft RAID picture

NVME M.2 Adapter Card PCIE X16 Splitter Expansion Controller 4-Disk Soft RAID

$24.43



G-Technology G-SPEED Studio XL 48TB Thunderbolt 2 Storage - Housing Only picture

G-Technology G-SPEED Studio XL 48TB Thunderbolt 2 Storage - Housing Only

$200.00



CalDigit VR minin 2 Portable Raid Storage On The Go picture

CalDigit VR minin 2 Portable Raid Storage On The Go

$75.00