Flag This Hub

How To Compile Java Using Console in Windows

By


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 YourProgram.java" 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.

Comments

Rudra 14 months ago

its getting more complicated by the day.

heroix 14 months ago

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 14 months ago

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

mERiCA 3 months 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.

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    Like this Hub?
    Please wait working