ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software

How To Compile Java Using Console in Windows

Updated on April 1, 2011

To compile .java programs first you need to get compiler. Get to download page here and select Download JDK. Then you'll have to select your Operating System. After downloading file you will have to install it and configure system variables. To make a configuration in Windows you have to Right Click on My Computer and select Properties -> Advanced System Settings (in left panel) -> Advanced Tab -> Environment Variables. Search for variable named PATH, if can't find create one and edit variable value to look something like this:

"C:\Program Files\Java\jdk1.6.0_24\bin"

It changes depending on where you have installed it. You have to find "bin" folder, where program "java.exe" and "javac.exe" executable files are. If there was some information already separate them with semicolons and write destinations in quotation-marks.

Now to compile I'd recommend you to put your .java files to "C:/java". Now open console by typing "CMD" in windows search. To open your java files folder write "cd C:/java", to compile it type "javac" and to see how it works write "java YourProgram".

That's it! If you'd like to ask something feel free to do that in comments below.


    0 of 8192 characters used
    Post Comment

    • profile image

      KHURSHEEd 4 years ago

      thanks. It worked for the windows

    • IncomeScientist profile image

      IncomeScientist 5 years ago

      Compiling Java from Windows console is a confusing process to start with... but the hub is nicely written.

    • heroix profile image

      Mantas Sinkevičius 5 years ago from Vilnius, Lithuania

      Try restarting your PC. Or just closing CMD and starting it again.

    • profile image

      mERiCA 5 years ago

      You may no longer be responding to this post, but I have followed all of the steps above and my command prompt still says that javac is not a command recognized... if i can't get this I think Ubuntu is calling me. Maybe Linux Mint. Minty fresh.

    • Rudra profile image

      Rudra 6 years ago

      Yes it is, to be honest, I find it pretty difficult to understand. but nicely explained, cheers.

    • heroix profile image

      Mantas Sinkevičius 6 years ago from Vilnius, Lithuania

      Well yeah, it is confusing. But that is just how to compile it with windows console. Linux way of doing it is way simpler, because you don't need to set any paths. And the easiest way is to compile it with IDE, such as NetBeans. But sometimes you need just simple pure console.

    • Rudra profile image

      Rudra 6 years ago

      its getting more complicated by the day.