File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Compile Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Compile Error" Watch "Compile Error" New topic
Author

Compile Error

Lakshmi siri
Ranch Hand

Joined: Feb 06, 2004
Posts: 44
Hi,
Iam new to servlets.I downloade j2sdkee1.3.1.
I downloaded tomcat5.0. And I set classpath
CLASSPATH - c:\Tomcat5.0\common\lib\servlet-api.jar
When i complile the following program.
C:\j2sdkee1.3.1\bin> javac -d . HelloWorldServlet.java
Error:
Exception in thread " main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
Program:
package examples;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.lang.*;
public class HelloWorldServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.printlln("<html>");
out.printlln("<body>");
out.printlln("<h1>Hello World!</hl>");
out.printlln("<body>");
out.printlln("<html>");
}
}
How can i compile this program.
Thanks for your help.
--Lakshmi
Ivan Tamayo
Ranch Hand

Joined: Aug 13, 2001
Posts: 49
In order to compile Servlets, you don�t have to download the entire J2EE.
What IDE or tool are you using?
jim chou
Greenhorn

Joined: Feb 15, 2004
Posts: 4
i check out the j2sdkee\bin,there is no javac.exe there,i think you must run in j2sdk\bin ,and put servlet.jar(you can find it in tomcat\common\lib) in j2sdk\jre\lib\ext,then you can compile it and may don't encounter any errors.
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Originally posted by jim chou:
i check out the j2sdkee\bin,there is no javac.exe there,i think you must run in j2sdk\bin ,and put servlet.jar(you can find it in tomcat\common\lib) in j2sdk\jre\lib\ext,then you can compile it and may don't encounter any errors.

Hello Jim,
To use some jar file, it best to set classpath. Even if servlet.jar is in tomcat\common\lib, setting the classpath of the jar file will be enough.


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Lakshmi siri
Ranch Hand

Joined: Feb 06, 2004
Posts: 44
Hi,
Thnaks for your help.I downloaded j2sdk1.4.1_04.Now my program is compiling without error.
--Lakshmi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compile Error
 
Similar Threads
learning servlets but getting IOException error
compile error
What's wrong with my basic servlet code
servlet class not compiling. Classpath problem?
JDOM works normally not with JSP