A java package is a group of similar types of classes, interfaces and sub-packages.
 
Step 1: Go to C: drive and create a folder named p
Step 2: Go to run, type cmd and on command prompt go to folder p
Step 3: Type simple.java program in folder p as below
package package1;  
public class simple
{  
           public static void main(String args[])
          {  
                   System.out.println("Welcome to package");  
          }  
}    
Step 4: Compile the program using javac -d . simple.java
            ( You can see the folder package1 is automatically created.
               and you can see the CLASS file is also created and saved in package1 folder) 
Step 5: Execute the program using    java package1.simple
            Output is as below:  Welcome to package
 
Comments
Post a Comment