Jump to content



How to: Compile and run a .java file in Windows with CMD

Windows 7 Java

  • Please log in to reply
No replies to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 08 October 2014 - 10:03 PM

Compiling and Running a .java file on Windows 7


The first thing you will need to do is to open CMD through the start menu. You can do this by following the images below.


Once you have this open, you can use the cd command to change to the directory where you have your java file stored. You can then use the dir command to make sure it is there. You can see an example of this using the image below.



The final thing is to compile and run our program. The command for this is as follows

javac Classname.java

to run the program, we type in

java Classname

You can see a full example in the image below



List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

Also tagged with one or more of these keywords: Windows 7, Java