GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Package does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Package does not exist " Watch "Package does not exist " New topic
Author

Package does not exist

lakshmanan anand
Greenhorn

Joined: Jan 13, 2009
Posts: 22
Hi,

I have two packages under my src directory.

  • com.example.web
  • com.example.model


  • I have BeerSelect.java in com.example.web
    and I have BeerExpert.java in com.example.model

    I first coded and compiled my BeerExpert class and it compiled without errors. But when i tried to compile BeerSelect class, package does not exist error comes..

    Here are my two classes





    The error when i try to compile BeerSelect class is


    Please help..


    http://luckydev07.blogspot.com
    Henry Wong
    author
    Sheriff

    Joined: Sep 28, 2004
    Posts: 18874
        
      40

    Please help..


    How exactly are you compiling? The directory that you are in? The command line?

    Henry


    Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
    lakshmanan anand
    Greenhorn

    Joined: Jan 13, 2009
    Posts: 22
    here is the command that i give to compile

    javac -d classes src\com\example\web\BeerSelect.java

    Henry Wong
    author
    Sheriff

    Joined: Sep 28, 2004
    Posts: 18874
        
      40

    lakshmanan anand wrote:here is the command that i give to compile

    javac -d classes src\com\example\web\BeerSelect.java




    Unless, you have a classpath set, you are in the wrong directory. Without the classpath, javac will assume that the current directory is the class path, which in this case, is wrong.

    You need to be in the src directory and compile with

    javac -d ..\classes com\example\web\BeerSelect.java

    You may also have to recompile the other class too.

    Henry
    lakshmanan anand
    Greenhorn

    Joined: Jan 13, 2009
    Posts: 22
    Henry Wong wrote:
    lakshmanan anand wrote:here is the command that i give to compile

    javac -d classes src\com\example\web\BeerSelect.java




    Unless, you have a classpath set, you are in the wrong directory. Without the classpath, javac will assume that the current directory is the class path, which in this case, is wrong.

    You need to be in the src directory and compile with

    javac -d ..\classes com\example\web\BeerSelect.java

    You may also have to recompile the other class too.

    Henry


    I went inside the src directory and compiled the class with your command, but still it gives me the same error... what else can i do ?
    lakshmanan anand
    Greenhorn

    Joined: Jan 13, 2009
    Posts: 22
    i just included the classes directory in my classpath.. and the problem was solved.
     
    GeeCON Prague 2014
     
    subject: Package does not exist