• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Package does not exists

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Below are my 2 packages, And receiving error compiling.

package packagea;
public class ClassA{
       void printa(){
       System.out.println("You are in packagea");
}
}


package packageb;
import packagea.ClassA;
public class ClassB{
   public static void main(String args[]){
       ClassA a = new ClassA();
       a.printa();
       System.out.println("you are in packageb");
   }
}


Error:

ClassB.java:2: error: package packagea does not exist
import packagea.ClassA;
              ^
ClassB.java:5: error: cannot find symbol
       ClassA a = new ClassA();
       ^
 symbol:   class ClassA
 location: class ClassB
ClassB.java:5: error: cannot find symbol
       ClassA a = new ClassA();
                      ^
 symbol:   class ClassA
 location: class ClassB
3 errors
 
Saloon Keeper
Posts: 7999
70
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the file folder structure for your project?

Welcome to the Ranch!

For future reference, UseCodeTags (<--link) will tell you how to enclose code listings inside Code Tags so that they are properly formatted with line numbers.
 
Marshal
Posts: 72406
315
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome again

Remembr the folder structure has to match the package structure. If you have two XXX.java files in the same directory with different package names, I think you can only compile both packages if you use a special option (−d).
 
yellanki Divya
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
got it now, thank you
 
Campbell Ritchie
Marshal
Posts: 72406
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done sorting it out What was the solution?
 
His brain is the size of a cherry pit! About the size of this ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic