File.exists() does not work on mac for non-English characters on Java 7 on Mac
Thorkelsson
thorkelsson at sidelinesports.com
Tue Oct 9 08:47:52 PDT 2012
Hi,
My name is Agust Thorkelsson and I'm the owner of a company called Sideline Sports. We produce software for professional sport coaches. We have encountered a huge problem that we can't seem to find a workaround for.
We have customers in many countries in Europe and almost all of them have non-english characters in filenames of files they use in our systems.
The Java 7 upgrade for Mac basically renders our software unusable. This is only on Mac.
Scott Kovatch instructed me to file a bug for this and e-mail this address for a discussion. I'm hoping you have some kind of workaround you can let us know about. It would be much appreciated! The filed bug can be seen beneath.
I'm sure this bug breaks a lot of Java software here in Europe and not in a clean way either. File.exists() is a popular method to use.
Again, thanks for any help you can give.
Best regards,
Agust
Agust Thorkelsson
Sideline Sports
thorkelsson at sidelinesports.com
www.sidelinesports.com
Mobile: +46 (0) 704 244 359
Office: +46 (0) 40 692 7942
Begin forwarded message:
> From: Þorvaldur Blöndal <thorvaldur at sidelinesports.com>
> Subject: Fw: Your Report (Review ID: 2356502) - File.exists() does not work on mac for non-English characters
> Date: 9 oktober 2012 14:22:08 CEST
> To: "Thorkelsson" <thorkelsson at sidelinesports.com>
>
>
> ----- Original Message ----- From: <Bug-Report-Daemon_WW at ORACLE.COM>
> To: <thorvaldur at sidelinesports.com>
> Sent: Tuesday, October 09, 2012 12:21 PM
> Subject: Your Report (Review ID: 2356502) - File.exists() does not work on mac for non-English characters
>
>
> Date Created: Tue Oct 09 06:21:15 MDT 2012
> Type: bug
> Customer Name: Þorvaldur Blöndal
> Customer Email: thorvaldur at sidelinesports.com
> SDN ID:
> status: Waiting
> Category: java
> Subcategory: classes_io
> Company: Sideline Sports
> release: 7
> hardware: x86
> OSversion: macosx
> priority: 3
> Synopsis: File.exists() does not work on mac for non-English characters
> Description:
> FULL PRODUCT VERSION :
> java.specification.vendor=Oracle Corporation
> java.runtime.version=1.7.0_10-ea-b10
> java.version=1.7.0_10-ea
> file.encoding.pkg=sun.io
>
>
> ADDITIONAL OS VERSION INFORMATION :
> os.name=Mac OS X
> os.version=10.8.1
>
>
> EXTRA RELEVANT SYSTEM CONFIGURATION :
> My Computer is in Icelandic. This also happens to a friend of mine in Sweden.
>
> A DESCRIPTION OF THE PROBLEM :
> Hi.
>
> Files (with non-English characters) that are returned by a File dialog return false from exists() if I double-click my jar. But if I run the jar from a terminal, exists() returns true.
>
> I'm using
> os.name=Mac OS X
> os.version=10.8.1
>
> I made a small test program. It opens a file dialog where I can select Files. It's much more successful if I run it from a terminal. I also tried to webstart it and run it from Netbeans. No success.
>
> I think this is related to these things:
> http://stackoverflow.com/questions/12509532/encoding-issues-on-java-7-file-names-in-os-x
> http://javafx-jira.kenai.com/browse/RT-23836
>
> The System.properties are quite different.
>
> When I run from terminal by typing "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" -jar TestProject.jar:
> java.specification.vendor=Oracle Corporation
> java.runtime.version=1.7.0_10-ea-b10
> java.version=1.7.0_10-ea
> file.encoding.pkg=sun.io
> user.country=IS
> sun.jnu.encoding=UTF-8
> file.encoding=UTF-8
> user.language=is
>
> When I double-click the jar in Finder:
> java.specification.vendor=Oracle Corporation
> java.runtime.version=1.7.0_10-ea-b10
> java.version=1.7.0_10-ea
> file.encoding.pkg=sun.io
> user.country=IS
> sun.jnu.encoding=US-ASCII
> file.encoding=US-ASCII
> user.language=is
>
>
> REGRESSION. Last worked in version 7
>
> STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
> Just deploy and run the attached code on a computer that contains files with atypical names. Like þæö.mp3.
>
> File.exists() does not work if you double-click a jar or webstart it.
>
> EXPECTED VERSUS ACTUAL BEHAVIOR :
> EXPECTED -
> I expected Files that are returned by a File Dialog to exist().
> ACTUAL -
> They did not.
>
> REPRODUCIBILITY :
> This bug can be reproduced always.
>
> ---------- BEGIN SOURCE ----------
> package testproject;
>
> import java.awt.FileDialog;
> import java.io.File;
> import java.util.Iterator;
> import java.util.Map.Entry;
> import javax.swing.JFrame;
> import javax.swing.JOptionPane;
> import javax.swing.JScrollPane;
> import javax.swing.JTextArea;
> import javax.swing.SwingUtilities;
>
> public class TestProject
> {
> public static void main(String[] args) throws Exception
> {
> SwingUtilities.invokeLater(new Runnable()
> {
> @Override
> public void run()
> {
> new TestProject();
> }
> });
> }
>
> public TestProject()
> {
> StringBuilder props = new StringBuilder();
> Iterator<Entry<Object, Object>> iter = System.getProperties().entrySet().iterator();
> while (iter.hasNext())
> {
> Entry<Object, Object> next = iter.next();
> props.append(next.getKey().toString()).append("=").append(next.getValue().toString()).append(System.getProperty("line.separator"));
> }
>
> JFrame frameProps = new JFrame("System Properties");
> frameProps.getContentPane().add(new JScrollPane(new JTextArea(props.toString())));
> frameProps.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> frameProps.pack();
> frameProps.setVisible(true);
>
> FileDialog fd = new FileDialog(frameProps);
> fd.setMode(FileDialog.LOAD);
>
> while (true)
> {
> fd.setVisible(true);
> String selDir = fd.getDirectory();
> String selFilename = fd.getFile();
> if (selDir == null || selFilename == null)
> break;
>
> File selected = new File(selDir, selFilename);
> if (selected == null)
> JOptionPane.showMessageDialog(frameProps, "file was null");
> else if (selected.exists())
> JOptionPane.showMessageDialog(frameProps, selected.getAbsolutePath() + " exists");
> else
> JOptionPane.showMessageDialog(frameProps, selected.getAbsolutePath() + " does not exist exists");
> }
> }
> }
>
> ---------- END SOURCE ----------
> workaround:
> comments: (company - Sideline Sports , email - thorvaldur at sidelinesports.com)
>
More information about the macosx-port-dev
mailing list