This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
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: 37940
    
  22
. . . and welcome to the Ranch
 
Don't get me started about those stupid light bulbs.
 
subject: Package error
 
Similar Threads
about protected methods
How does this work ?
hashmap
problem with writing calculator application
Access Modifier/Package