This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Compilation Error  RSS feed

 
Ram Sankaran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple servlet (copied from a book) and when I try to compile it, I get an error that reads:
SimpleServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
I take it that my actual code is irrelevant as it is failing to pick up the import stmt itself.
I am compiling as follows: (entire command is on one line)
D:\>javac -classpath .;D:\jdk1.3\lib\*.jar;D:\jdk1.3\jakarta-tomcat-3.2.3\lib\*.jar SimpleServlet.java
I have checked that servlet.jar file exists in my path as specified above. I even opened up servlet.jar and checked that the path says javax.servlet for the Servlet class file.
How else do I troubleshoot, what else do I look for?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


D:\>javac -classpath .;D:\jdk1.3\lib\*.jar;D:\jdk1.3\jakarta-tomcat-3.2.3\lib\*.jar
SimpleServlet.java

- instead I would spell out each jar file not *.jar
- otherwise I would set the env variable "classpath" with all
the jars spelled out file by file and
then compile.
$0.02
- satya

 
Ram Sankaran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you suggesting that that is the cause of my problem? Or are you merely suggesting a better way to do it?
 
Ram Sankaran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!! I am amazed that instead of putting *.jar, putting servlet.jar compiled the program. Your $0.02 are worth many times more in terms of my solving my problem.
Now the question arises, is *.jar a bad idea then? I have always used *.jar for my JAVA programs and that never caused any trouble. Are the servlet jars treated differently by javac?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now the question arises, is *.jar a bad idea then? I have always used *.jar for my JAVA
programs and that never caused any trouble.

From what has been said here (D:|), I am assuming you
are on some kinda Windows box. And in light of this, I am
not qualified enough to comment on Why it works sometimes and
why it doesn't at other times. Maybe Bill Gates or
Steve Balmer could....
- satya
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a Unix environment the wildcards are expanded by the shell before the application is invoked. Under Windows, it's up to the application to do so --- if it chooses.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!