pTutorial

New way to learn Programming

How to run java program in cmd

How to compile java program?

Open CMD (command Prompt) and type

javac Name_of_Java_file

In case of Hello.java file

Javac Hello.java

How to run java program?

Open CMD (command Prompt) and Type

java Name_of_the_class_file

For example in above case

Java Hello

How to check the current version of java?

Open the command prompt (cmd), to open CMD press window + R and type cmd and type

java -version

C:\Users\umarkhan>java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM)64-Bit Server VM (build 25.5-b02,mixed mode)
C:\Users\umarkhan>
how to install JDK

What does it mean "java is not recognized as an internal or external command?"

If you are facing problem like below shown, that means you could not set path properly that’s why windows command prompt does not know about the any tool of java like java, javac or Javadoc. So its time to set path. Path could be temporary or permanent. Click here to set the path in java.

javac is not recognized as an internal or external command

Can we run the java program without setting the path?

Yes of course you can run java program without setting the path of jdk/bin folder. In that case you have to save your java source file inside the jdk/bin folder.


QUOTES OF THE DAY

Eat to live, and not live for eat.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER