Thursday, April 19, 2012

Hi,
Today i want to share how java program is compile and run when it have a package structure.
I know there is a lot of material available on net which can give you idea of how it will achieve but below i will give you simple way to do that.


SimpleCompileRunProject.java

package com.learning.sampleproject;

public class SimpleCompileRunPriject{

      public static void main(String[] args){
        System.out.println("Sample compile and run the project");
      }
}

Compile : javac  SimpleCompileRunProject .java


If you are using the java SimpleCompileRunProject  it will give you the exception
  could not find the main class :  SimpleCompileRunProject . Program will exist. 
To resolve this issue you have to compile and by using the below code.

Compile : javac -d  .   SimpleCompileRunProject .java


Run : java com.learning.sampleproject.SimpleCompileRunProject



If you need any help then mail me below is my mail address.
megha31.sanghvi@gmail.com

bye for now.