Sei sulla pagina 1di 2

7/11/2017 How to Run Java Program in CMD - pTutorial

pTutorial Custom Search


New way to learn Programming

Home PHP Functions Example C Example Java Ajax Tutorial Blog

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

1 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

1 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

1 C:\Users\umarkhan>java -version
2 java version "1.8.0_05"
3 Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
4 Java HotSpot(TM)64-Bit Server VM (build 25.5-b02,mixed mode)
5 C:\Users\umarkhan>

http://www.ptutorial.com/how-to-run-java-program-in-cmd 1/2
7/11/2017 How to Run Java Program in CMD - pTutorial

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 thats 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.

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.

Programming tutorial
1,066 likes

Like Page Contact Us

Be the first of your friends to like this

http://www.ptutorial.com/how-to-run-java-program-in-cmd 2/2

Potrebbero piacerti anche