Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath idiocy

 
Aodhan Hoffman
Ranch Hand
Posts: 35
Java MyEclipse IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running into a problem trying to compile servlets and building a package.
Unless I specify the servlet api package specifically when compiling, java can't find it, despite the fact that the package is explicitly described in the path.

echo $CLASSPATH
.:/Users/Aodhan/servdev:/Library/Tomcat/home/common/lib/servlet-api.jar:.

$javac HtmlHelper.java
HtmlHelper.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
HtmlHelper.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
2 errors

$javac -classpath /Library/Tomcat/home/common/lib/servlet-api.jar HtmlHelper.java
$

------------------

additionally, when trying to create a package, I get the following error:

New-Orleans/~/servdev/gryf/523 aodhan $jserv HelloServlet3.java
HelloServlet3.java:13: cannot resolve symbol
symbol : class HtmlHelper
location: package gryf
out.println( gryf.HtmlHelper.getHead(" Hello Servlet 3 " ) +
^
HelloServlet3.java:14: cannot resolve symbol
symbol : class HtmlHelper
location: package gryf
"Hello 3!" + gryf.HtmlHelper.getFoot() );
^
2 errors

HtmlHelper.java and HelloServlet3.java are both in ~/servdev/gryf/ and both are specified as part of package gryf. If I compile HelloServlet3.java as part of package gryf but without reference to HtmlHelper.java, no problem.

$head HtmlHelper.java
package gryf;

import javax.servlet.*;
import javax.servlet.http.*;

public class HtmlHelper
{
public static String getHead( String title )
{
...

$head HelloServlet3.java
package gryf;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet3 extends HttpServlet
{
public void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
...

-------------


Any idea what kind of noob mistake I'm making? Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic