• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package error

 
Dishita Shah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic