You are here
Home > Java > Hello World in Java

Hello World in Java

Hello friends, Today I am gonna show you how to create a first and basic program in Java and before that I’ll tell you how to setup Java on your computer.

Installing Java

Step 1: First you have to download JDK and you can download it from Here.

Step 2: Now after completing your download, double click on downloaded file to start intallation process (if it is an installable exe file) otherwise if it and zip file then uncompress it your desired location on your computer.

Step 3: Now find bin folder from your installation directory (installation directory is by default Program Files directory which is in window installation directory), then after finding bin directory copy path to bin from address bar. ie. (C:\Program Files\Java\jdk1.8.0_45\bin)

Step 4: Now Press (Window + R) to open run utility and type¬†SystemPropertiesAdvanced¬†in run utility and click Ok or press Enter. Now you will see new window named as System Properties. Now click on Environment Variables button, now again a window will open named as Environment Variables, from here add a variable under user variables or System variables by clicking on New button. Enter Variable name Path and paste path which you’d copied in step 3 in Variable value and press Ok and close all window by pressing Ok button on each window/dialog.

Step 5: Now to check again press Window + R to open run utility and then type cmd and press Enter, Now command prompt will open then type javac and press Enter. Now if everything goes ok then you will see javac command usage otherwise you will see javac is not recognized as internal or external command.

Hello World Program

Step 1: Open notepad or any text editor you like.

Step 2: Type code given below or you can just copy and paste it.

Step 3: Save your file as “Test.java”¬†on desired location ie. Desktop, My Documents, etc. on your computer.

Step 4: Open command prompt by typing cmd in run utility, then go to the location where you saved your file using cd command.

Step 5: Now type javac Test.java on command prompt and press enter, Now if everything goes ok then your code will be compiled without any message, if any error occurs then error get shown. If any error occurs then check error message and correct your code and compile it again using javac command.

Step 6: To run your program type java Test (Here Test is class name which we written in code not file name).

Output

Hello World

Thanks

You may share if you like it

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.
http://www.zatackcoder.com

Comments

zatackcoder
Top