You can compile and run programs using command prompts with help of command environment tools or using IDEs.
To run with command prompts we need first set path environment variable for java command environment tools.
To run and compile with IDEs we need set JAVA_HOME environment variable .
To set path
Open the properties of "My Computer
Open a window named "System Properties"
Click on the "Advanced" tab
Then
click "Environment Variables"
Next,
another window opens
Double-click on the "Path" variable on either of the option boxes.
Don’t delete anything in this box.
At the end of the text box, add a semi-colon & add "; C:\Program Files\Java\jdk1.5.0_10\bin" to the text box.
Click "Apply" and "OK" to all the windows you have just opened.
Open the new command prompt again,
To check open cmd and type javac and press enter
C:\ >javac
Then Following will display . Usage: javac
where possible options include:
-g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath Specify where to find user class files -cp Specify where to find user class files
-sourcepath Specify where to find input source files -bootclasspath Override location of bootstrap class files -extdirs Override location of installed extensions -endorseddirs Override location of endorsed standards path
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system