Social Icons

Pages

Featured Posts

Friday, August 31, 2012

How to Compile and Run Java file in jdk1.6.0_25 Using Command Prompt

Just make sure you have Java in your computer, if you don't have it, just download it on the java website.

Compiling and running java file in jdk1.6.0_25 is very easy. I will show you the steps so just follow them.

1. First, do your code on notepad and save them as "filename.java".

 Click "Save as..."




2. Save your file in the folder "bin" with the format "filename.java".

Click My Computer > Program Files > Java > jdk1.6.0_25 > bin > Save as "filename.java".



3. Now to compile and run the java file using Command Prompt, follow these steps:

Open Command prompt. Click Start > Run > Then type "CMD" in the type box and click "OK".



Then the command prompt will appear.

On the command prompt, type "cd\".




Then type "cd Program Files".
Now you're now on C:\Program Files\




Next, type "cd Java". Now you're on C:\Program Files\Java.
Continue typing until you reach the folder "bin".
After cd Java, type "cd jdk1.6.0_25"
Next, "cd bin".
You are now on C:\Program Files\Java\jdk1.6.0_25\bin
Compile now the java file.type "javac filename.java".
It will now show you if you have errors, if you have no errors, Congrats! you have successfully compile the java file.

Now run it by typing "java filename".

Cheers!