Cannot run Java from the Windows PowerShell command prompt

前端 未结 9 847
野性不改
野性不改 2020-12-16 16:55

I have Java installed on my machine (the JRE is under C:\\Program Files\\Java) but I can\'t run any java command from the Windows PowerShell command prompt.

相关标签:
9条回答
  • 2020-12-16 17:27

    Add it to C:/Program Files/Java/jre7/bin added to the classpath environment variable.

    0 讨论(0)
  • 2020-12-16 17:33

    If it works in cmd, but not in PowerShell, your JDK path entry might be in quotes.

    As described in an answer to another question, go to system variables, edit the raw text of Path and simply remove the quotes.

    0 讨论(0)
  • 2020-12-16 17:36
    • In the run dialog box, enter sysdm.cpl
    • In the window that came up, navigate to Advanced tab. Click on the Environment Variables button.
    • Add the location of your java installation (the bin directory) to the PATH variable.

      ;%ProgramFiles%/Java/jre%version%/bin
      

      followed by a ;

    Note:

    %version% means the java version.
    
    0 讨论(0)
  • 2020-12-16 17:36

    If it works in the regular shell but not in PowerShell, maybe you had PowerShell open when you installed or set your path and you just need to close PowerShell and reopen a new one to pick up the new path.

    0 讨论(0)
  • 2020-12-16 17:38

    You need to set the Java class path:

    Reference:

    How to set class path?

    Or:

    Link-2: How to set class path?

    0 讨论(0)
  • 2020-12-16 17:40

    You need to modify your "PATH" environment variable to add your "java" bin location, one way via command prompt set path=%path%;<your java bin location>;

    But this will be set only for your current session of your terminal.

    0 讨论(0)
提交回复
热议问题