• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

classpath idiocy

 
Ranch Hand
Posts: 35
MyEclipse IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic