aspose file tools*
The moose likes Beginning Java and the fly likes package does not exist problem 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 problem" Watch "package does not exist problem" New topic
Author

package does not exist problem

K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 68
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

Where did you put the compiled class file?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rao Raghu
Ranch Hand

Joined: Jan 05, 2007
Posts: 100
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.


RAGHU<br /> <br />"When the going gets tough, the tough get going"
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
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 .)


~Sanjeev Singh<br />SCJP 1.5
K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 68
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: package does not exist problem