• home
  • forum
  • my
  • kt
  • download
  • How to compile and run a Java program

    Author: 2008-08-12 14:01:51 From:

    The syntax to compile a java program is

    javac filename. java

    Syntax to run a java program:

    java filename

    Creating a Java Application

    1. Code the application
    2. Compile and Execute the application
    First Java Program

    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();

    }
    }

    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

    relation tutorial

    No relevant information

    Category

      Applet Building (2)
      Application Building (4)
      Communication (1)
      Database Related (10)
      Development (13)
      EJB (14)
      Game Programming (5)
      General Java (58)
      Javabeans (4)
      JSP and Servlets (8)
      Miscellaneous (28)
      Networking (1)
      Security (2)
      Swing (13)
      WAP and WML (2)
      XML and Java (4)

    New

    Hot