There are various steps to compiling and running java programs, these are
Step-1 : First to install JDK, JRE and JVM into the System.
Step-2 : Prepare source code in any editor like notepad, c++ editor etc.
Step-3:
class HelloWorld
{
public static void main(String r[])
{
int a=10, b=10,c;
c=a+b;
System.out.println("Output of the program is"+c);
}
}
Step-4 : Save the source code in the java bin directory. Class name which contain main method should same of the file name.
Example : HelloWorld (class name)
HelloWorld.java (file name)
Step-5 : Open command prompt and change the directory where your java program has been saved.
Suppose your java software installed in C:/>. Now, compiling steps is:
C:/java/jdk1.7.0/bin> Javac filename.java (press Enter)
C:/java/jdk1.7.0/bin> Java filename.java (press Enter)
Step-6: During compilation, if program generate errors, it means you can't run your program.
Step-1 : First to install JDK, JRE and JVM into the System.
Step-2 : Prepare source code in any editor like notepad, c++ editor etc.
Step-3:
class HelloWorld
{
public static void main(String r[])
{
int a=10, b=10,c;
c=a+b;
System.out.println("Output of the program is"+c);
}
}
Step-4 : Save the source code in the java bin directory. Class name which contain main method should same of the file name.
Example : HelloWorld (class name)
HelloWorld.java (file name)
Step-5 : Open command prompt and change the directory where your java program has been saved.
Suppose your java software installed in C:/>. Now, compiling steps is:
C:/java/jdk1.7.0/bin> Javac filename.java (press Enter)
C:/java/jdk1.7.0/bin> Java filename.java (press Enter)
Step-6: During compilation, if program generate errors, it means you can't run your program.