Hi Friends,
Yesterday I was struggling with programming in Java and searched a lot of sites to know about it. Each and every site confused me and so now that I have written for you in easy steps so that you can work with java easily.
Step 1: write the Java code using Notepad.
The java program for eg: hello.java should be typed in notepad first . Now save it in the format(.java) in the location>> C:\Program Files\Java\jdk1.6.0_07\bin.
Remember: You need to save it under jdk\bin . The location of the same can be found where you have installed java. I have installed java in c drive under program files.
step 2: working with command prompt
Now that you have written the java code and you need to run to get the output.
So, go to start >> Run >> type cmd.
Now command prompt opens up.
type cd..
type cd..
Now you have changed the directory to c drive
c:\>
Now you must go to the location C:\Program Files\Java\jdk1.6.0_07\bin.
So, from c:\> what commands should I type to move to bin directory?
Step 3: Moving to Bin Directory
c:\> cd [space] program files
Now it has moved to
c:\program files\>
Similarly you must type
c:\program files\> cd[space] java
and so on till bin reaches.
c:\program files\Java\jdk1.6.0_07\bin>
Step 4 Debugging the program.
So, once the bin is reached type
c:\program files\Java\jdk1.6.0_07\bin> javac [space] hello.java
This will check whether if there are some errors in it. If there are no errors then it will come back to the same bin location
c:\program files\Java\jdk1.6.0_07\bin>
step5: Running the Program
Now type the following command to run the program
c:\program files\Java\jdk1.6.0_07\bin> java[space] classname
whats classname?
In the java program type the classname which contains the code for output.
Now you can get the output!! cool !!
No comments:
Post a Comment