This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Package error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package error" Watch "Package error" New topic
Author

Package error

Dishita Shah
Greenhorn

Joined: Feb 25, 2012
Posts: 1
I 've created a class within the package p1 which i import in another class.
This program works perfectly fine in the IDEs(I used Eclipse),
but shows the following error when run through the command prompt:
Error:
package p1 does not exists.

My files are:
the class in package p1:




the class which imports package p1:



please let me know whats causing this error.
Thank you in advance.
Viktor Kubinec
Ranch Hand

Joined: Jan 28, 2012
Posts: 34
Make sure that your classpath and folder structure is right. It should look like this :

<root>
|
|- p1
| |
| |-Student.java
|
|- Test.java

so class Sudent is in p1 package and Test is in default package (no package).

if you run

javac -cp . Test.java

from the root folder it should work.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39079
    
  23
. . . and welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package error