Klook.com
jasa pembuatan repository kampus

How to Use the Command Prompt to Work With Java

How to Use the Command Prompt to Work With Java

This tutorial will show you how to run Java on your computer using Command Line

1. To use command prompt for java, you will have to install the JDK.

2. Download the JDK SE(Standard edition) from that website and install it.

3. Once you’ve installed it, open up its installation directory(Unless you change it,the default is ‘C:Program FilesJavajdkx.x_xx’, where xx.xx is the version number.)- In the jdk folder, open the folder ‘bin’, and copy the complete path from the address bar, or from the properties of any of the files in the folder bin.- If you cannot find the installation directory or the bin folder, that means you did not install it right. Reinstall it and retry step 3.

4. Open command prompt.- To open command prompt, click on Start, then click on Run, type ‘cmd’ in it and press enter.

5. After you open the command prompt, write ‘path=’ and paste the path you have copied earlier from the bin folder (Note: ctrl+v does not work in command prompt for pasting, use right click).- When you do this step right,you will get no reply but your working directory printed again(something like ‘C:UsersYourUserName’).- But if you do it wrong, you will get an error. Retry from step 3.- Now your command prompt is ready to compile a Java program.

6. Write your program.- To write your program, you will need some text editor like Notepad or Notepad++.- Write your Program in it and save it as YourClassName.java(eg. MyClass.java).- You can Write any program and if you don’t have one, you can use our Java: Simple program to display a message.

7. Now Change the working directory to where you have saved your program.- Changing the working directory:* To do that, open the folder where you have saved your program and copy the complete path from the address bar or from the properties of your program.* Then in command prompt, type ‘cd ‘ Paste your path here.- When you do this step right, your working directory should now change to the folder where your program is saved.

8. Compile your program.- To Compile, write ‘javac’ filename.java* Again, when you do it right, you will get no confirmation but your working directory printed again and have a class file named same as your program file, i.e., filename.class in your working directory.* If you do it wrong, you will get an error.

9. Run your program.- To run your program, run the class file just made from the command prompt.- To do that write ‘java’ filename.class.

10. Thats it! Your program should run now.

About the Author: admin

Kangdadang earned his Diploma degree from dr Otten Academy of Nursing, Bandung in 2002. 2010 He joined the accounting graduate program In economics faculty at The University of Kepulauan Riau. He received his Master of Science degree in Human Resource in 2013 from The University of Batam. While his work at local government, Kang Dadang also interest on IM, today he manage many blog and owner of Pesonaweb.com
//graizoah.com/afu.php?zoneid=3423089
%d bloggers like this: