Results 1 to 5 of 5
Thread: .java won't compile
- 03-29-2010, 06:11 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 12
- Rep Power
- 0
.java won't compile
I'm having trouble getting a simple .java to compile
here are the errorJava Code: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 { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println( "<HTML> <BODY> <H1>Hello World !</H1> </BODY></HTML>"); } }
here is the classpath locationJava Code:paul@paul-laptop:~$ javac -cp . HelloWorld.java HelloWorld.java:2: package javax.servlet does not exist import javax.servlet.*; ^ HelloWorld.java:3: package javax.servlet.http does not exist import javax.servlet.http.*; ^ HelloWorld.java:5: cannot find symbol symbol: class HttpServlet public class HelloWorld extends HttpServlet { ^ HelloWorld.java:6: cannot find symbol symbol : class HttpServletRequest location: class HelloWorld public void doGet(HttpServletRequest request, ^ HelloWorld.java:7: cannot find symbol symbol : class HttpServletResponse location: class HelloWorld HttpServletResponse response) ^ HelloWorld.java:8: cannot find symbol symbol : class ServletException location: class HelloWorld throws ServletException, IOException { ^ 6 errors
Java Code:paul@paul-laptop:~$ echo $CLASSPATH /home/paul/apache-tomcat-6.0.18/lib/servlet-api.jar:/home/paul/apache-tomcat-6.0.18/lib/jsp-api.jar
any ideas why this will not compile
- 03-29-2010, 06:23 PM #2
Member
- Join Date
- Nov 2009
- Posts
- 12
- Rep Power
- 0
solved
I usedwhen before i was usingJava Code:javac
Anyone any idea why it wansn't working to begin with as javac -cp . should workJava Code:javac -cp . HelloWorld.java
- 03-29-2010, 06:25 PM #3
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
The -cp option overrides the CLASSPATH environment variable. When you did '-cp .' you wiped out the Tomcat directories in your CLASSPATH.
-Gary-
- 03-29-2010, 09:41 PM #4
Member
- Join Date
- Mar 2010
- Posts
- 2
- Rep Power
- 0
i will advice you to go and download netbeans with web application to be able to run your servlets
- 03-30-2010, 06:58 AM #5
hi,
you has to compile with the jar file with -cp option
like this
C:\Documents and Settings\Desktop>javac -cp "D:/samples/javax.servlet.jar" HelloWorld.java
this is windows i dont know how the same doing in linus based patforms
ok
you will get the jar from http://www.java2s.com/Code/Jar/STUVW...servletjar.htmLast edited by javastuden; 03-30-2010 at 06:59 AM. Reason: add
Similar Threads
-
New to JAVA and code cant compile
By Gayethiri_86 in forum New To JavaReplies: 2Last Post: 03-05-2010, 06:43 AM -
Compile and Run a Java package
By hussain in forum New To JavaReplies: 1Last Post: 09-10-2009, 09:15 AM -
Java’s “Compile Once Run Anywhere”, where does it fail?
By h8alfred in forum Advanced JavaReplies: 5Last Post: 03-26-2009, 06:24 AM -
My Java program will not compile and run?
By sabrown311313 in forum Java AppletsReplies: 1Last Post: 09-23-2008, 09:38 AM -
Help with Java Compile File
By baltimore in forum New To JavaReplies: 1Last Post: 08-06-2007, 07:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks