SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Apr 2002
    Location
    Whitehorse, Yukon
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JSP Servlet will not compile

    I am attempting to compile the trusty ol' HelloWorld.java into a servlet. I'm working with Win 2000, Apache 2.0.43 and Tomcat 4.1.12. My JSP pages compile with no issues, it's just that when I write the java file myself it doesn't work. I have checked over several times and can only think that I don't have my machine set up correctly. I have no idea

    My CLASSPATH is set up this way:

    .;c:\j2sdk1.4.0_02\lib\tools.jar;c:\apache\tomcat\common\lib\servlet.jar

    Here's my process.

    1) Write the .java file. Save it to C:\Apache\Tomcat\common\classes.

    2) I open a Command Prompt, navigate to my directory above and type javac HelloWorld.java.

    3) I get an error message stating - 'javac' is not recognized as an internal or external command, operable program or batch file.

    What does this mean? Is something in my setup incorrect? My HelloWorld file looks to me as if it is not missing anything either.

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class HelloWorld extends HttpServlet {
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException

    {
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("An HTML Hello World");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>Hello World</H1>");
    out.println("</BODY>");
    out.println("</HTML>");
    }
    }

    What gives?

    Thanks so much to anybody who can respond with an answer. This is really holding me back in learning and running through my JSP book's tutorials.

    geof

  2. #2
    As the name suggests... trickie's Avatar
    Join Date
    Jul 2002
    Location
    Melbourne, Australia
    Posts
    678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure that the location of the javac binary is in your PATH.

    I think on Windows the PATH is set in the autoexec.bat or something like that. I'm not sure but try something like the following in the command prompt. (I don't use windows so you might have to play around a bit with the command):

    PHP Code:
    $PATH=%PATH%whereEverTheBinaryIs
    Last edited by trickie; Oct 14, 2002 at 07:49.

  3. #3
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: JSP Servlet will not compile

    Originally posted by Geof Harries
    I am attempting to compile the trusty ol' HelloWorld.java into a servlet. I'm working with Win 2000, Apache 2.0.43 and Tomcat 4.1.12. My JSP pages compile with no issues, it's just that when I write the java file myself it doesn't work. I have checked over several times and can only think that I don't have my machine set up correctly. I have no idea

    My CLASSPATH is set up this way:

    .;c:\j2sdk1.4.0_02\lib\tools.jar;c:\apache\tomcat\common\lib\servlet.jar

    Here's my process.

    1) Write the .java file. Save it to C:\Apache\Tomcat\common\classes.

    2) I open a Command Prompt, navigate to my directory above and type javac HelloWorld.java.

    3) I get an error message stating - 'javac' is not recognized as an internal or external command, operable program or batch file.

    What does this mean? Is something in my setup incorrect? My HelloWorld file looks to me as if it is not missing anything either.

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;

    public class HelloWorld extends HttpServlet {
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException

    {
    PrintWriter out = response.getWriter();
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("An HTML Hello World");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>Hello World</H1>");
    out.println("</BODY>");
    out.println("</HTML>");
    }
    }

    What gives?

    Thanks so much to anybody who can respond with an answer. This is really holding me back in learning and running through my JSP book's tutorials.

    geof
    so did you try any of the example .java scripts that came installed when you installed the sdk.
    i love php

  4. #4
    SitePoint Member
    Join Date
    Oct 2002
    Location
    United States of Europe (USE)
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try adding the following to the "Path" variable in the "Environment Variables" section of your Win2K machine.


    c:\j2sdk1.4.0_02\bin


    Hope this helps.
    Last edited by delboy_trotter; Oct 23, 2002 at 17:45.

  5. #5
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try adding the following to the "CLASSPATH"

    c:\apache\tomcat\classes;
    hope this helps u,

  6. #6
    SitePoint Addict
    Join Date
    Apr 2002
    Location
    Whitehorse, Yukon
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks everybody for the replies. I am going to try some of this stuff today and I'll post back what happens.

    geof


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •