You require Arabic fonts in your OS.
As someone said be sure your prompt or terminal is set to UTF-8
You may need to install into your OS the Arabic "locale" so it can be set down in the taskbar for use with the prompt or terminal.
You should specify compiling your class file in UTF-8 for javac with the -encoding flag , and the source file should be saved in UTF-8.
You may need to consolidate string charset for it's charset version.
String.format() method.
Anything manipulating charsets requires wrapping in a java.io.UnsupportedEncodingException including any e.g. new String constructors nominating a charset!
https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
try{
String name1 = String.format(new Locale("ar"),"%s",new String(name1.getBytes("UTF-8"),"UTF-8"));
catch(java.io.UnsupportedEncodingException charstex){
charstex.printStackTrace();
}
Visual Studio foreign languages
https://code.visualstudio.com/docs/getstarted/locales
Too, with windows, you can open the prompt as the top window, then right click on the little square with two letters in the taskbar along the bottom of the desktop, it should open a dialog widow with the list of languages for input and output. If Arabic is there it should be able to be selected. Putting in both a web charset for Arabic and a generic ordinary mainly used charset for Arabic can greatly help too after installing Arabic if it is not there.
Info on prompt chcp 65001
Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)
Java supported charset encodings cp1256 windows Arabic. ,. ISO8859-6. Latin/Arabic mixture.
https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
Did youu see the "%s" argument in format() method? In Linux right clicking on the terminal edge should do a popup specific to the terminal, but if you only have an "en" Operating System you need to put in the international locales from the install disc, and in windows per OS for specific I think professional version is required or you may be able to download that locale, whether it's free or not I don't know.
Fonts
You would need to install some generic Arabic font files too if the OS (Operating System) was only one language e.g. only English.