• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"package does not exist" error

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem--glad you figured it out :)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic