How to set up your computer to begin programming with Java?
Step 1 : Download & Install JDK (Java Development Kit)
- Download JDK from here. If you already have it then you skip this part.
Step 2 : Setting System Variables
1. Go to Control Panel of your computer, select System Properties from the menu and select Advanced Settings.
2. Click on Environment Variables and you this window will appear.
3. Under the System Variables section find PATH variable. If you find the PATH variable in the list then go to Step 4 otherwise skip to Step 5.
4. Click on Edit button below the list and you will be shown Edit System Variable window. There will be some paths already added in Variable Value field. To add new path for jdk that you have installed already, you have to put a ';' (semicolon) and then path of your jdk's bin directory in Variable Value field.
(Usually it is C:\Program Files\Java\jdk1.8.0_05\bin where, jdk version may vary)
5. If the PATH variable is not listed under the System Variables, you can create new variable by clicking on New button below the list. Set "Path" as Variable Name and set the path of your bin folder of jdk in Variable Value field.
(Usually it is C:\Program Files\Java\jdk1.8.0_05\bin where, jdk version may vary)
Step 3 : Creating and Executing a Java file
1. You can create a java program using various software or using Notepad. Create a sample program for java as shown below. Here created file using Notepad and Saved it as "Test.java".
(NOTE: Name of your File must be same as the Class name which contains the Main method)
2. Now open command prompt. (To start command prompt press Windows button + R with your keyboard. A Run box will be appeared, type cmd in it and hit enter) In command prompt window, type "javac Test.java". 'javac' command compiles the java program and if you don't find any errors in your program, you will be taken to the same directory. Now type 'java Test'. Note that for compiling a program you have to write file name with java extension whereas for executing it you have to write only the file name with 'java' command.