Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


deepak patidar
package:
1 Answer(s)      3 years ago
Posted in : Java Interview Questions


i hv created created a package and save it into D directive and also set permanent path when i compile it ,it compile successfully but it can't run with following command: java mypackage.classname

what's problem ?


Advertisement
View Answers

September 28, 2011 at 3:22 PM


Suppose we have a file called HelloWorld.java, and put this file in a package world. The we specify the keyword package with the name of the package.

package world;

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}

When compiling HelloWorld class, just go to the world directory and type the command:

C:\world\javac HelloWorld.java

Then run as:

C:\world>java world.HelloWorld


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com