The syntax to compile a java program is
javac filename. java
Syntax to run a java program:
java filename
Creating a Java Application
- Code the application
- Compile and Execute the application
You need to write the code to create an application that consists of class. Class also contains methods. In addition you need to define the main() method that creates an object of the class and executes the methods inside the class.
import java.io.*;
class firstpgm
{
firstpgm()
{
System.out.println(“ Welcome to Java Tutorials”);
}
}
class firstsample
{
public static void main(String args[])
{
firstpgm b = new firstpgm();
}
}
class firstpgm
{
firstpgm()
{
System.out.println(“ Welcome to Java Tutorials”);
}
}
class firstsample
{
public static void main(String args[])
{
firstpgm b = new firstpgm();
}
}
Always save the java program in the name of the class where the main method is defined with extension .java.
The output of our first java application would be:
Welcome to Java Tutorials
discuss this topic to forum
