aspose file tools*
The moose likes Java in General and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark ""package does not exist" error" Watch ""package does not exist" error" New topic
Author

"package does not exist" error

Shajid Johnny
Ranch Hand

Joined: May 15, 2010
Posts: 34
Dear members,
I am developing a Java web project. in my 'src' folder- I have the following two classes:

1)


2)


First, from my project root directory I compiled the model class:
E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\apache-tomcat-
6.0.20\apache-tomcat-6.0.20\lib\servlet-api.jar" -d classes src\com\foo\model\BookExpert.java

But later when I tried to compile the controller servlet:
E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\apache-tomcat-
6.0.20\apache-tomcat-6.0.20\lib\servlet-api.jar" -d classes src\com\foo\controller\BookSelectServlet.java

I got the following errors:
src\com\foo\controller\BookSelectServlet.java:8: package com.foo.model does not exist
import com.foo.model.*;
^
src\com\foo\controller\BookSelectServlet.java:25: cannot find symbol
symbol : class BookExpert


though the model class BookExpert was successfully built inside the classes/com/foo/model directory, still the controller servlet did not compile

please anyone help me out of the pain i am suffering from the last night
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

You never add "E:\SCWCD preparation\HF Projects\javaEbook\classes\" to your classpath, so the package found at E:\SCWCD preparation\HF Projects\javaEbook\classes/com/foo/model/ can't be found.


Steve
Shajid Johnny
Ranch Hand

Joined: May 15, 2010
Posts: 34
Steve Luke wrote:You never add "E:\SCWCD preparation\HF Projects\javaEbook\classes\" to your classpath, so the package found at E:\SCWCD preparation\HF Projects\javaEbook\classes/com/foo/model/ can't be found.


so, what should I do now? should I add this classpath into the command line with the older one:

E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\apache-tomcat-
6.0.20\apache-tomcat-6.0.20\lib\servlet-api.jar" -d classes src\com\foo\controller\BookSelectServlet.java


will it work if i use two class paths in -cp option???
Shajid Johnny
Ranch Hand

Joined: May 15, 2010
Posts: 34
adding two classpath in the command line does not work

E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\Tomcat\lib\servlet-api.jar" -cp "E:\SCWCD preparation\HF Projects\javaEbook\classes" -d classes src\com\foo\controller\BookSelectServlet.java


can you please tell me what should i do???
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

You don't add a second -cp parameter, you add to the existing one using a semicolon:

E:\SCWCD preparation\HF Projects\javaEbook>javac -cp "C:\My Tools\Tomcat\lib\servlet-api.jar;E:\SCWCD preparation\HF Projects\javaEbook\classes" -d classes src\com\foo\controller\BookSelectServlet.java
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The classpath separator in Windows is ";". One classpath, multiple components.
Shajid Johnny
Ranch Hand

Joined: May 15, 2010
Posts: 34
Thank you!
Thank you!!
Thank you!!!

it worked!

thanks a lot. now i can concentrate on some useful coding
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No problem--glad you figured it out :)
 
jQuery in Action, 2nd edition
 
subject: "package does not exist" error