Jump to content

  •  

Photo

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

Wilson18

    Administrator

  • 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.

post-1-0-06115400-1412805359.png

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.

post-1-0-84855200-1412805532.png

 

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

post-1-0-13410500-1412805690.png

 


List what you read?

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






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