• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help on Import package  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I'm a begginner in java. So please bear with me. Below is what I'm trying to do .

I have a class BeerSelect.java under c:\testProject\src\com\example\web
and I also have a another class BeerExpert.java under c:\testProject\src\com\example\model.

In the BeerSelect.java I'm importing com.example.model.BeerExpert.

When I try to compile javac -d classes src\com\example\web\BeerSelect.java, I get the "Package com.example.model does not exisit" error message.

What am I doing wrong?

Thanks for your time
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

First see if the BeerExpert.java has been compiled and the BeerExpert class file has been generated in the respective package that you have used in BeerExpert.java.

Example- if you have used the package name as com.example.model in the BeerExpert.java and you successfully compile the file then search for the BeerExpert.class file. It should be generated in the same directory structure as you have used for the package.So you should see a com directory which has a example subdirectory which inturn has a subdirectory model which will have your class file.

If the class file has been created in com.example.model package then include the superdirectory of com in your classpath.
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if THIS helps. It has examples of importing from jars and from other directories of your own.
 
Sanju Shah
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI ,

Thanks for taking time to respond to my posting. I do see BeerExpert.class created in the same directory structure as mentioned in the package. But still when I try to do javac -d classes src/com/example/BeerSelect.java I get the same error Package com.example.model.BeerExpert does not exist.

What is it that I need to set with classpath.? Can you please show me an example.?

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!