简体   繁体   中英

I can not run Java on Visual Studio Code! I tried a lot

My problem is that I can not run Java on Visual Studio Code. I downloaded all extension and JDK but there is an issue and error when I run the code..

I took a screenshot for my problem.

here is the code:

public class Hello {

    public static void main(String[] args) {
        System.out.println("hi");
    }
}

here is the error in the terminal:

Copyright (C) Microsoft Corporation. All rights reserved.


Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Ahmed\Desktop\LearnJava>  & 'c:\Users\me\.vscode\extensions\vscjava.vscode-java-debug-0.26.0\scripts\launcher.bat' 'C:\Program Files\Java\jdk-13.0.2\bin\java.exe' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\me\AppData\Roaming\Code\User\workspaceStorage\869d91d9e4b3718bf03724a877036fed\redhat.java\jdt_ws\LearnJava_9276adca\bin' 'Hello'
ahl
PS C:\Users\me\Desktop\LearnJava>

here is the error in the output:

Running] cd "c:\Users\me\Desktop\LearnJava\" && javac Hello.java && java Hello

[Done] exited with code=0 in 4.348 seconds

[Running] cd "c:\Users\me\Desktop\LearnJava\" && javac Hello.java && java Hello
ahl

[Done] exited with code=0 in 1.152 seconds

[Running] cd "c:\Users\me\Desktop\LearnJava\" && javac Hello.java && java Hello
ahl

[Done] exited with code=0 in 1.236 seconds

[Running] cd "c:\Users\me\Desktop\LearnJava\" && javac Hello.java && java Hello
ahl

[Done] exited with code=0 in 1.157 seconds

From the outputs you give out, everything works well, partly. Both of debugger and code-runner. The only problem you run across is the outputs are not what you expected. It's more like a cache problem, you can try to create a new.java file, or delete the cache folder: 'C:\Users\me\AppData\Roaming\Code\User\workspaceStorage\869d91d9e4b3718bf03724a877036fed'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM