Forum Stats

  • 3,874,337 Users
  • 2,266,724 Discussions


compiling and running java programs

I have downloaded Java for Completed some code in Notepad. I cannot find where to compile the code and test it.


  • KatAlive
    KatAlive Member Posts: 3 Green Ribbon


    To make it very easy, i suggest you to download IDE like Eclipse or Netbeans, they are very useful, also because they include all Javadocs and suggestions meanwhile you're writing the code.

    Then, if you wanna continue to use notepad :

    1. Save the file as
    2. open command prompt (cmd) on Windows, if you are Mac OS then open Terminal.
    3. To compile the program, type the following command :

    If you get this error : “javac’ is not recognized as an internal or external command, operable program or batch file“, you need to set the path before compilation; so :

    • Open command prompt (cmd), go to the place where you have installed java on your system and locate the bin directory, copy the complete path and write it in the command like this.
    set path=C:\Program Files\Java\jdk1.8.0_121\bin

    When the PATH is ok, try again STEP 3 to compile and then run program with :

    java FirstJavaProgram

    That's it.