Home > Software design >  Java commands flash a cmd
Java commands flash a cmd

Time:07-17

I'm new to Java. I already installed Java, JDK and added it to Path, but when I try to run a command (like "java -version") it just flashes a CMD but doesn't show what I want to see. This happens with every command and doesn't even let me run Java code using an IDE. There is no error message, just a CMD flashing every time I try to run something (it also happens when double click the files like "java", "javac", etc).

CodePudding user response:

How do you run these commands? Try running them from an interactive terminal window. Open it by typing windows key R and then cmd. Then cd into your directory and type your commands there. Alternatively, if your commands are in a .bat file … you may add a pause command at the end.

CodePudding user response:

This is entirely expected as java -version immediately exits after printing the version. This means that if you didn't start it from cmd, PowerShell, or another interactive shell, it opens a window which disappears immediately because the program ended in a fraction of a second.

Start cmd (Command Prompt) or PowerShell (either directly or through Windows Terminal), and run your commands in that interactive shell.

  •  Tags:  
  • java
  • Related