• Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot compile my servlet?

 
carl varola
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following servlet class in a package called abc,it uses an object of a class called box that is whithin same package abc and cannot get it to compile.
The error is "cannot resolve symbol
symbol : class box "
I have a directory called abc under classes directory under web-in and I'm using Tomcat.
--------------------------------
package abc;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class TestServlet extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hello World!!!");
box b = new box();
out.println(b.hello());
}
}

-----------------------------------------
package abc;
public class box
{
public String hello()
{
return "Hello World";
}
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17290
9
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a side note, there is already a Box class in J2SE. It is part of Swing.
Mark
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some problem with your classpath, maybe?
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error was due to the compiler could not see the box.class under the abc directory.
First compile just the Box.java and "make sure" the Box.class is in the directory called abc. Then compile the servlet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!