This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package does not exist problem

 
K Vidhyakar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you put the compiled class file?
 
Rao Raghu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • 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.
 
Sanjeev Singh
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic