【问题标题】:VS Code The system cannot find the path specifiedVS Code 系统找不到指定的路径
【发布时间】:2021-06-04 08:03:39
【问题描述】:

我正在尝试在 VS 代码上运行我的学校作业,但我收到了这个错误。 我已经在家里运行了我的代码,它总是运行得很好,但是这个文件就是不想运行。

这是我从终端得到的

Copyright (C) Microsoft Corporation. All rights reserved.

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

PS C:\Users\orave\Google Drive\APCSA\PROG 2\Introduction & Analysis of Algorithms\Sorting Stats\selection&insertionSort>  & 'c:\Users\orave\.vscode\extensions\vscjava.vscode-java-debug-0.31.0\scripts\launcher.bat' 'C:\Program Files\AdoptOpenJDK\jdk-11.0.9.101-hotspot\bin\java.exe' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\orave\AppData\Roaming\Code\User\workspaceStorage\3e4f84fdbcb8ec16980a673d4ef46a02\redhat.java\jdt_ws\selection&insertionSort_48006976\bin' 'sortingAlgorithms'
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]      
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

 Arguments following the main class, source file, -jar <jarfile>,
 -m or --module <module>/<mainclass> are passed as the arguments to
 main class.

 where options include: // just some arguments

The system cannot find the path specified.

【问题讨论】:

    标签: java visual-studio-code terminal path


    【解决方案1】:

    在我获得足够的声望之前,我显然不能将 cmets 留在其他职位上。我打算请您分享您尝试运行的代码以及您认为可能有助于更好地理解导致此问题的任何其他信息。自上次运行代码以来发生了什么变化?

    我看到你的 PATH 中有一个空格,这里:

    C:\Users\orave\Google Drive\APCSA\PROG
    

    我过去在 VS Code 上遇到过这样的问题,像这样的 PATH 不起作用:

    C:\Program Files\Microchip\xc8\v2.32\bin\xc8.exe
    

    错误信息:

    C:\Users\raymu_000\Documents\Programming\VisualStudioCode\PIC_C_on_VSCode\L298N-
    MotorDriver_Test>C:\Program Files\Microchip\xc8\v2.32\bin\xc8.exe
    --chip=16f887 --outdir="./output-files" --output=lpp "./Project/init-PWM.c"
    
    'C:\Program' is not recognized as an internal or external command, operable program or batch file.
    

    这个可以通过在具体路径两边加引号“”来解决

    "C:\Program Files\Microchip\xc8\v2.32\bin\xc8.exe"
    

    或者这样写:

    C:\Progra~1\Microchip\xc8\v2.32\bin\xc8.exe
    

    但我坚持认为,您应该为您的问题添加更多上下文。希望这在某种程度上有所帮助。

    【讨论】:

    • @PatrickOrave。您的代码在我的机器上运行良好。正如 R4Y-Nevarez 所说,错误可能与路径中的空格有关。将此文件移动到路径不包含空格的另一个目录并再次运行它以查看此问题是否消失。
    • 试过了,它消失了,我的代码第一次尝试,所以我很高兴!
    【解决方案2】:

    我将 VS 代码打开到我的学校文件夹中,而不是我的项目文件夹中,编译器希望在与主文件相同的文件夹中运行。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案3】:

    @Ray-Nevarez: 没错,文件夹路径中的空间是问题所在。我有一个类似的问题 - 在某些情况下更改默认文件夹可能无济于事,因为某些人无权更改它或由于某些原因不想更改路径。 最好在 VSCode 上包含文件的完整路径 - 它对我有用。 我的文件夹路径位于 Google Drive G:\My Drive\VSCODES.... 我在三个不同的位置使用三台不同的 PC。我更喜欢同步我的文件并在任何位置方便地工作,而无需远程连接到另一台 PC。 注意:确保在文件夹名称中包含引号中的空格。 例如:G:\My Drive\VSCODE,(My Drive 应该是“My Drive”)。

    【讨论】:

    • 尽量不要让你的答案因为冗长的流程而杂乱无章,打破文本并使其更加清晰和有条理。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-23
    • 2018-12-12
    • 2016-04-23
    • 2017-01-04
    • 2014-04-24
    • 2017-03-03
    相关资源
    最近更新 更多