Friday, December 21, 2012

0 How to Compile Java by Command Line(cmd)

1.Run command prompt(cmd) Start->Accessories->cmd.exe.
2.Type your java files directory in cmd.(eg: cd c:\myJavaPro)
3.After this you want to type javac <your file name>.java
if the cmd shows an error like this then we can understand jdk class path is not set in your system.









4.to set class path type  set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
or
Right click on computer->properties->
















advanced system settings->











 in advanced tab select Environment variables->


















in system variables select variable named "PATH" then Click EDIT


















 at the end of variable value put a semi colon and paste the jdk class path(eg:c:\program files\java\jdk\bin).









Then repeat step 3

5.It will create a .class file in your java files folder(eg: filename.class).
then type java <class file name> and press enter then the program be executed.

Thursday, November 22, 2012

0 Java Basic Syntax


package javaapplication6;


public class Main
{
    public static void main(String[] args)
    {
    System.out.print("MY FIRST JAVA PROGRAM");
    }
}


This program shows  how to print a simple text in java .
in the above example the "javaapplication6" is the program Package(Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier etc)..

"Main" is the Class(A class can be defined as a template/ blue print that describe the behaviors/states that object of its type support).

"main() Method" It is compulsory in  java program, when you execute a class in java the run time will start it's execution by calling the main Method. the main method  then calls the other methods required to run .

The "System.out.print()" is a java method to print plane text..



 

Code Sea Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates