This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package error" Watch "Package error" New topic

Package error

Dishita Shah

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:
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 :

|- p1
| |
| |

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

if you run

javac -cp .

from the root folder it should work.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46424
. . . and welcome to the Ranch
I agree. Here's the link:
subject: Package error
It's not a secret anymore!