• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to compile with utilityclass  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to compile a file with utility class
the code(file) is:
--------------------------
package moreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet3 extends HttpServlet {
...........
out.println(ServletUtilities.headWithTitle(title));
...........
}
the code of utility class
--------------
package moreservlets;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletUtilities {
...........
}
first of all ,i compile the utility class by typing " javac -d C:\jakarta-tomcat-4.0.3\webapps\ROOT\WEB-INF\classes ServletUtilities.java"
it worked well, and ServletUtilities.class was put in the directory of moreservlets , but when i try to compile HelloServlet3.java by using the way above,there is error message,
"HelloServlet3.java:23: cannot resolve symbol
symbol : variable ServletUtilities
location: class moreservlets.HelloServlet3
out.println(ServletUtilities.headWithTitle(title) +
^
1 error "
what is the correct way of compiling utility class??
 
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your HelloServlet3 class you print out a line using:
ServletUtilities.headWithTitle(title)
This is a call to a method. Apparently there is no STATIC method in ServletUtilities that is named headWithTitle() so the compiler thinks that there MUST be an instance of the ServletUtilities class referenced in a variable named ServletUtilities. After all, you seem to be making a call to a method using that variable, so . . . .
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(From david)
hello, Cindy
i m afraid you havnot understood what i mean.
There is no STATIC method in ServletUtilities that is named headWithTitle() ,which i omitted.
i want to know what is the correct way to complie the these two files with the same package. As i said i first compiled ServletUtility.java successfully, but i cnat compile HelloServlet3.java , the error message is like what i wrote in last post.
i think there should be something wrong but not the codes themselves, because they are example codes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!