1. Install jdk1.6 (latest version) on your system. (If any issues in installation, do ask here). Look at the following link for downloads Java SE Downloads - Sun Developer Network (SDN)
2. Create a source folder in your system where all your Java programs will be stored (let it be C:\JavaSrcCode..This is my system made folder. I would recommed you all to make following folder structure D:\MyJava\source)
3. Create Example.java file in the above created folder(My is JavaSrcCode, your will be 'source' folder) Example.java (Details of this file is discussed in next post ) [CODE] public class Example{ public static void main(String args[]){ System.out.println("Hello Example Test"); } } [/CODE] 4. Now for compiling from command prompt a)Switch your location to bin directory of installed location of your java(C:\Program Files\Java\jdk1.6.0_02\bin) b)Now from that location type "javac
[QUOTE=shalini_goel14;42353][Day1 Class Contd..] If anyone here wants me to put some light on object-oriented concepts. Do let me know. As it is theoretical concept so I am not going into it here ok. So now coming to writing a simple basic Program in java : I will consider the program written in above post [code] public class Example{ public static void main(String args[]){ System.out.println("Hello Example Test"); } }[/code] A simple class program in Java represents a generic thing for any real world object Now for writing a Java Program 1. Open notepad (if not using Java IDE) and save the file with .java extension in source folder (the one we created in step 2 of last post) Let me name that file as Example.java 2. Now add following lines of code for creating the class public class Example { } [Note: 1. Always remember the Java class name should match with that of the file name for example in above post case. The file name was Example.java which was exactly same as class name in code(public class Example). 2. Java is case-sensitive language. ] So now my Java class is defined. 3. Now add following lines: public static void main(String args[]){ } Look carefully here Above lines of code is much similar like creating a method of name main Here public means this method is accessible from anywhere outside the class. As main method here is accessible as it must be called by code outside of its class when program is started. Now keyword static allows main() to be called without having to instantiate a particular instance of the class (Will teach in further lectures how to instantiate a class). Actually this is infact necessary since main() is called by JVM before any objects are made. The keyword void simply tells the compiler that main() does not return a value. Any information that we need to pass to the method is received by the variables(called as parameters) specified within the set of parentheses followed by the name of the method. So in above main() method there is only one parameter named as args which is an array of instances of the class String.Here args receives any command-line arguments present when the program is executed. { and } shows the main method's body start and end. 4. Next add the following line of code in main() method's body System.out.println("Hello Example Test"); Here System is a predefined class that provides access to the system and out is the output stream that is connected to the console.println() displays the string which is passed to it. Notice that println() command end with a semicolon ; . So with all this I take leave from this thread and hope you all would have enjoyed the first day with Java. [Assignment: Setting up the environment on your system and writing a simple Java program that will print "Hello World " in output. ][/QUOTE]