Issue
I used JOptionPane.showInputDialog
and TextInputDialog
for getting user input like this:
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("ورودی");
dialog.setHeaderText("لطفا شماره انبار را وارد کنید");
dialog.getDialogPane().setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
Optional<String> anbarId = dialog.showAndWait();
anbarId.ifPresent(s ->
{
if (!s.equals("")) {
anbarLabel.setText(s);
}
}
);
but when i run executable jar file it shows me wrong characters: Wrong characters on dialog
I used maven assembly plugin to create executable jar file here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ansar</groupId>
<artifactId>Jeticket</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.2.1.jre8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ansar.application.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
Solution
finally i solved this problem by changing my jre version to 1.8.271 and using 'String.valueOf()'
Answered By - Sepehr Mollaei
Answer Checked By - David Marino (JavaFixing Volunteer)