I'm having a big problem with my computer, as I try to compile source code made in Java language, hence a great frustration:
The variable of type String is poorly read and interpreted by the compiler and prints squares instead of special characters.
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Name:");
String name = sc.nextLine();
System.out.println(name);
}
}
Result:
My attempts were:
Change the "netbeans.conf" configuration file in the IDE's files folder located in File Explorer
Install multiple versions of NetBeans IDE to see if this problem occurs in all versions. Yes, it occurs in all versions and I have tried all the program's configuration alternatives
Uninstall and Install the version of the JDK on my computer and to ensure I also installed the JRE on my machine to see if the problem was resolved after installing all these programs. Nothing resolved and without success. The problem continued to compile this little code in the IDE.
With this problem, I can't:
- Create applications with databases (MySQL + JDBC) in the Java language, because the parameters of the PreparedStatement object do not recognize the special characters of the String due to this problem
Create Java applications in general, because if this problem occurs that, in my opinion, seems like an impossible solution to be solved on my computer, how will I continue to create systems with this special character recognition error?
Compile source code on my computer, as the compiler does not recognize special characters like ç, á, ã, â, í, among others and instead of displaying them in the output, squares appear as you saw in the previous image.
Was it some configuration that was left behind or is it a solution that I am not able to develop to fix this problem? And if so, what would be the best explanation for solving this problem? Will it be necessary to contact the technician for more information?
I am grateful that @Tigris helped me with this problem, which actually when I went to check I ended up making a storm in a glass of water. The @Tigris solution in the comments gave me an idea that became immediate when I analyzed the error I was giving with the answer he initially gave me.
The problem was simple, it was basically a character encoding error in the IDE's terminal that was solved with the line I typed in CMD:
This solution is related to the link at the end of the comments and in it you notice that the explanation of the post indicates that the problem can be solved with a simple line of code that sets a system property.
But after solving this problem and analyzing the link that @Tigris shared here in the comments, I was thinking: If my problem hadn’t solved and still insisted on showing special characters in an unreadable way, then I would have to insert the answered line of code posting on all my projects?
That is why it is always good to check the device's character string right when it comes from the factory or even a repair, because depending on the occasion when this display problem of special characters can change the database that the user is working in case be a developer or even to build an API or Webservice for a client without paying attention to these details of textual stress, which can cause inconvenience and headaches when finishing a project in any IDE that is installed on the computer.