File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile Error

 
Lakshmi siri
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to compile Servlets, you don�t have to download the entire J2EE.
What IDE or tool are you using?
 
jim chou
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 452
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lakshmi siri
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thnaks for your help.I downloaded j2sdk1.4.1_04.Now my program is compiling without error.
--Lakshmi
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic