Friday, June 8, 2018

How to run java code on command prompt on windows 7

To run java code on windows 7 CMD, please follow the steps bellow

  1. First go to you local directory and copy the java bin directory
    Here is my java bin directory. You may have different according to your JDK version
    C:\Program Files\Java\jdk1.7.0_40\bin
  2. Then open you cmd or command prompt and write the following line then paste the directoryC:\\>set path="C:\Program Files\Java\jdk1.7.0_40\bin" and press enter.
    You will successfully set up the path.
  3. Now open you notepad and write a simple java code and save it as Hello.java and save on your Desktop.
  4. Then again goto cmd and locate you directory where you save the file. As I saved my Hello.java on Desktop so I can change my directory by following command.
    C:\\>cd Desktop
    and Then write the following command and press enter to compile your java file
    C:\\Desktop>javac Hello.java
    If your java code have no error it will compile fine otherwise it will show error messages.
    Then to run the code write the following command and press enter.
    C:\\Desktop>java Hello

No comments:

Post a Comment

Recent Post