jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes classpath idiocy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath idiocy" Watch "classpath idiocy" New topic
Author

classpath idiocy

Aodhan Hoffman
Ranch Hand

Joined: May 21, 2004
Posts: 35

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!


-------<br /> Aodhan H - Ad Astra Per Aspera<br /> -------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpath idiocy
 
Similar Threads
compile errors
compile problem w/ code in HFS book
Basic Servlet Compilation Problem
javax.servlet.http.* missing?
Servlets not compiling