vscode-java-debug icon indicating copy to clipboard operation
vscode-java-debug copied to clipboard

How to set the *.argfile encoding type ?

Open aewnfin opened this issue 3 years ago • 3 comments
trafficstars

[provide a description of the issue]

Environment
  • Operating System:
  • JDK version:
  • Visual Studio Code version:
  • Java extension version:
  • Java Debugger extension version:
Steps To Reproduce
  1. .vscode/settings.ison as follows: "[java]": { "files.encoding": "utf8" }, The command line is shown below: java @*.argfile com.example.demo.MainApp 错误: 无法初始化主类 com.example.demo.MainApp 原因: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
  2. The encoding of the file *.argfile is utf-8 ,java couldn't identify it correctly
  3. I want to set the encoding of the file to GBK ,what should I do ? The following settings are not valid: "[bat]": { "files.encoding": "gbk" }, "files.associations": { "*.argfile": "bat" }

[attach a sample project reproducing the error] attach logs

Current Result
Expected Result
Additional Informations

aewnfin avatar Jan 20 '22 09:01 aewnfin

My maven repository contains Chinese path "D:\备份\LocalRepository\apache-maven"

aewnfin avatar Jan 20 '22 09:01 aewnfin

*.argfile is auto generated by Java debugger, you cannot change its encoding through settings.json. ~~From my experiment, it seems the encoding of *.argfile is not important. On Windows, I add Chinese string to the classpath, then run the app with *.argfile, it works well for me.~~

image

Based on my experience, if you want to use Chinese file path or input/output Chinese characters in Java, the best way is to change your current system locale to Chinese.

image

Update: The program will report "java.lang.NoClassDefFoundError" if it accesses the class from the Chinese classpath. image

testforstephen avatar Jan 21 '22 12:01 testforstephen

Current workaround is to disable *.argfile. Go to .vscode/launch.json, change the launch setting to "shortenCommandLine": "none".

If launch.json doesn't exist, use the following approach to generate one first. image

testforstephen avatar Jan 21 '22 13:01 testforstephen