Saturday, March 28, 2015

How to run java program | Java jdk | Java runtime

To compile and run java program you need JDK that is java development kit installed in your computer. You can download JDK from oracle website or from here by clicking the following link


After installing jdk you need to set variable path. In order to do that please follow the following steps:
  1. Goto C:\ drive and open program files and in that open java folder. In that you will see jdk1.8.0_20 folder. Open it. In this you will see bin folder open it up and copy its path.
  2. Now right click on my computer folder on desktop and go to properties. In that in the left hand side you will see Advanced System Settings. open it and a pop up will come. On advance tab click on environment variables. Click on new. On variable name you have to write "path" and in path copy that address of bin folder which we had copied in step one.
  3. Now select that new variable and click OK. Now the environment variable is set.

The following are the steps to write and run our first java program using notepad and cmd:-
  1. Open notepad and write the same code snippet and save it with name First.java
  2. Open command prompt(cmd) and write cd.. This command is used to change directory. Change it till you get it into that folder in which your First.java resides.
  3. Now write javac First.java. This will compile our program. Javac is for java compiler.
  4. Now write java First. It will run our program and you will see the output which is Hello World! in our case.
The following are  the steps to run program in eclipse software:First you need eclipse software. You can download it by clicking on the link below:

  1. Open up this file  and eclipse will be launched but if you are getting trouble then you have to download it from internet.
  2. Go to the file menu and point to new and then click on other . A pop up will appear. Write dynamic web project there and then specify the name of the project then click next and simply your project will be created.
  3. If it is asking for Java EE then click no.
  4. Now click on the project that you just created and on src folder right click and then point to new and then click on package.
  5. Then write package name generally we write like this package name:"com.company_name.project_name".
  6. Click on finish.
  7. Now a package is created in your src folder of project.
  8. Now right click on package and point to new then click on class.
  9. Now write class name of your wish which is First in our case and then click OK.
  10. Now write the whole code in this class and run it from top and you will get output below the program in console.
From now onwards we will be writing our programs mostly in eclipse.

 

0 comments:

Post a Comment