1

I am using Hindi fonts in my project and when I am running it on Netbeans it works fine, but when I am run its .jar file it does not load Hindi font, but shows some garbage things. I am using UTF-8 encoding in Netbeans, and Arial Unicode MS font.

When running from Netbeans:

When running from Netbeans

When running .jar file:

When running .jar file

There are no issues in English. Thanks in advance.

Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49
  • 1
    Edit your question and show the code which calls `Font.createFont`. – VGR Aug 16 '18 at 19:06
  • 1) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 2) Application resources will become embedded resources by the time of deployment, so it is wise to start accessing them as if they were, right now. An [tag:embedded-resource] must be accessed by URL rather than file. See the [info. page for embedded resource](http://stackoverflow.com/tags/embedded-resource/info) for how to form the URL. – Andrew Thompson Aug 16 '18 at 22:47
  • *I am using UTF-8 encoding in Netbeans*: And which encoding do you use when running the .jar file? Probably not UTF-8. – Thomas Fritsch Aug 17 '18 at 07:23
  • Possible duplicate of [Setting the default Java character encoding?](https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding) – Thomas Fritsch Aug 17 '18 at 07:32
  • 1
    how do I use utf-8 when runninh .jar file – Priyanshu Patel Aug 17 '18 at 14:26

1 Answers1

1

I have solved my problem, it was happening because I was using UTF-8 in NetBeans, but .jar file was using some other encoding. So when reading the file I gave CharSet UTF-8.

List<String> s=  Files.readAllLines(Paths.get(langPath + "\\" + ExcerciseList.getSelectedValue() + ".txt"),Charset.forName("UTF-8"));
  • I am also facing the same problem. Can you explain this in detail? if I have to convert only one filed of the database into Hindi font then what should I do? – Mukesh Chauhan Nov 20 '19 at 03:51