Long codes before output in VSCODE (Java)

懵懂的女人 提交于 2021-01-07 02:45:53

问题


I am using Visual Studio Code to run a simple Java "Hello World" program. But I also get some long codes before my output "Hello, World!".

myusername hi % cd /Users/myusername/Desktop/Programming/hi ; /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:51164 --enable-preview -XX:+ShowCodeDetailsInExceptionMessages -Dfile.encoding=UTF-8 -cp "/Users/myusername/Library/Application Support/Code/User/workspaceStorage/9d9a27fdd962858fd296255e0827be55/redhat.java/jdt_ws/hi_a18a0468/bin" App Hello, World!

I don't really understand these codes before or the reason for it, is that normal? How could I remove these codes from my terminal and make my output simple?


回答1:


These are execution scripts and VS Code displays them to let developers know what's going on during this process, including

  1. the current used JDK: Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/bin/java

  2. network and displaying message rules: agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:51164 --enable-preview -XX:+ShowCodeDetailsInExceptionMessages -Dfile.encoding=UTF-8 -cp

  3. classpath and cache location: /Users/myusername/Library/Application Support/Code/User/workspaceStorage/9d9a27fdd962858fd296255e0827be55/redhat.java/jdt_ws/hi_a18a0468/bin

  4. the name of current .java file: App

There're some ways to get clear output without these scripts:

  1. Set "console": "internalConsole" in launch.json, the result will be displayed in Debug Console:

  1. Set "console": "externalTerminal" in launch.json, the result will be displayed in the new opened terminal:

  1. Install Code Runner and add the following code in Settings.json, the result will be shown purely in OUTPUT:

     "code-runner.clearPreviousOutput": true,
     "code-runner.showExecutionMessage": false,
    




回答2:


MacOS set default Java (JDK) Open Terminal

Step 1. /usr/libexec/java_home -V

Step 2. export JAVA_HOME=/usr/libexec/java_home -v 1.8

Step 3. java -version

java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
Up:~ xxx$

Good jobs.



来源:https://stackoverflow.com/questions/64776510/long-codes-before-output-in-vscode-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!