• 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 problem

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

When i try the following program, it says package does not exist.




E:\progms\java\scwcdtests\beerV1>javac -d classes src/com/example/model/BeerExpe
rt.java
Note: src/com/example/model/BeerExpert.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.




E:\progms\java\scwcdtests\beerV1>javac -d classes src/com/example/web/BeerSelect
.java
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src/com/example/web/BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:17: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors


help me in resolving this issue.
i already gone through similar topics but i am not able to understand the problem.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did you put the compiled class file?
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are compiling in command prompt, try setting the classpath to the com folder , I mean like this:
Classpath=%Classpath%;E:/..../com;

When you do this all the classes inside this package will be available.
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are compiling a class having package like

package com.example.web;


So some needful like compile from the folder where these classes are,so if classes are in folder src,go till src and then compile.In your case you did a mistake that you are compiling one folder up from the desired one.

E:\progms\java\scwcdtests\beerV1\src>javac -d classes com/example/model/BeerExpert.java


Set the classpath to all the library required to compile and also the current directory.

SET CLASSPATH=%CLASSPATH%;E:\progms\java\scwcdtests\beerV1\classes;.(look at the .)

 
K Vidhyakar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

this is my class path.
D:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar;E:\progms\java\scwcdtests\beerV1\classes

when i compile ,

E:\progms\java\scwcdtests\beerV1>javac src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/BeerSelect.java:5: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src/com/example/web/BeerSelect.java:9: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
src/com/example/web/BeerSelect.java:10: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse respo
nse)
^
src/com/example/web/BeerSelect.java:10: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request, HttpServletResponse respo
nse)
^
src/com/example/web/BeerSelect.java:11: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {
^
6 errors

now whats the problem...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This indicates that the servlet API is not in your classpath.

Check to make sure that your classpath has no typos or other errors and that it is in scope during compilation.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See:
http://faq.javaranch.com/view?CompilingServlets
for information regarding dependencies for compiling servlets.

Since this is really a javac/classpath issue and not servlet specific, I'm going to move the thread to Java In General (Beginner).
That is the best forum on this site for these types of problems.

-Ben
 
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic