Basics that everyone must know to create a Java program

Posted by jineesh uvantavida on Thursday, January 6, 2011 Under: Java
For a beginner to start creating programs in Java,
1. Install Java environment. (JDK)
2. Write a Java Program.
a. Write the Java program in a text document and save it with ".java" extension.
b. The name of the java file should be the class name in the program.
3. Compile Java Program.
a. To compile the java program using command prompt, we have to use some commands.
- Open DOS prompt. (Press "Window+R" -->> write "cmd" --->> press "Enter")
- Change the command prompt directory to the directory that your java program is saved.( Eg:  "c:\java" -->> press "Enter" if your java program is in a directory named "java" in the "c: " drive.
- Use the following command to set the path of the java compiler. (set path=%path%;"c:\Program Files\Java\Jdk1.6\bin" -->> press "Enter" )
- Use "javac HelloWorld.java" command to run HelloWorld program.
- Compiling of Java program is now completed if there is no errors in your program and a class file is formed in the same folder named HelloWorld.class
2. Run Java Program.
- To run the Java Program type " java HelloWorld "
- You will be getting the output printed on the command screen.

In : Java 



Translate This Page

 


Make a free website with Yola