Cannot run Java from the Windows PowerShell command prompt

前端 未结 9 848
野性不改
野性不改 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:41

    I fixed this problem by reinstalling Git-2.8.2-64-bit.exe and following these instructions! https://learn.adafruit.com/windows-tools-for-the-electrical-engineer/git-plus-command-line-tools

    I then added the code mentioned above c:\Program Files\Java\jdk-11.0.3\bin by navigating to control panel /system/Advanced tab Click on the Environment Variables then the system's variables and looked for Path then edited it. then added c:\Program Files\Java\jdk-11.0.3\bin and all is working for me now in a Windows PowerShell and also a MinGW64! See images of it working! Windows power shell

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

    Make 2 environment variable changes:

    1.  Add a JAVA_HOME variable equal to something like:  C:\Java\JDK1.7.0_25_x64
    2.  Add %JAVA_HOME%\bin to the beginning of your PATH variable.
    

    Then, start a brand new shell to see if the changes were applied.

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

    If the environment variable is set or you have sourced the environment appropriately, the issue is executing a file in a shell:

    javac .\HelloWorld.java      //That is a file, so it can be ./
    
    java HelloWorld              //Not the correct file name, so it will not execute, and so must call it as in MSDOS
    

    You cannot .\ on the HelloWorld.class as the Java bytecode must be executed without the extension, .\ is for file execution.

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