**Interactive equation of a circle. Click and drag to see equation in action!


A+    A−    B  
Home
Algebra
Math Games
  • Decimals in Space
  • Fraction Balls
  • Integers in Space
  • Math Man
  • Number Balls
  • Geometry
    Interactive
    Trigonometry
    Jobs
  • Tutoring jobs
  • New York Tutoring Jobs
  • White Plains, NY
  • Westchester County, NY
  • Chicago Math Jobs
  • Philadelphia
  • Teacher Resources
    On FaceBook!

    How to compile Java Source code from the command Prompt

    Using javac to compile .java files

    First off, this tutorial is based on using windows Vista. XP should work basically the same.

    Part I: Locate Javac

    • Before you do anything else, make sure that you have jdk installed on your computer. You also will need to know the directory to the jdk. Specifically, you will need the path to the Java compilier(javac) that is inside your jdk folder. My path to javac is:
       C:\"Program Files"\Java\jdk1.6.0_02\bin\javac
      
      • As you can probably tell, I'm using Java 1.6 and within the 'bin' folder is javac which is the Java compiler . Basically that line above tells the command prompt that we're going to run the java compiler (javac) which is located in the folder C:\"Program Files"\Java\jdk1.6.0_02\bin
      • The path to javac on your computer will probably look similar, it depends on where you installed the jdk to.

    Part II : Compiling with Javac

    In this example, I am going to use javac to compile a java source file called Hi.java which is saved on my desktop.





  • First, open up a command prompt. If you're using vista, you must run 'as administrator' for this example to work.
  • My command prompt immediately puts me in the system32 folder. We need to navigate out of this folder to the desktop.
  • How to Run the class file from the command Prompt
    Compiling ia a lot of fun and all, but the whole point in compiling a program is being able to run it! Let's now run my Hi.class file. I would like to show you the source code for this class so that you know what this trivial class does:
    public class Hi{
    public static void main(String[] args){	 
    		System.out.println("hi");	
    		}
    }
    
    Assuming that you are in the same folder as your class Hi.class. You can easily run this program by simply typing java Hi . NOTE: you do not append the file extension ".class". Typing Java Hi.class will cause an error.

    Top