• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

"package does not exist" error  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shajid Johnny
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath separator in Windows is ";". One classpath, multiple components.
 
Shajid Johnny
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
Thank you!!
Thank you!!!

it worked!

thanks a lot. now i can concentrate on some useful coding
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem--glad you figured it out :)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!