|
|
|||
Problem from Servlets & JSP in compiling 1st servlet
Please help a "newbie"! I've setup netbeans as well as the Sun JDK and can not compile the 1st servlet example from the Head First Servlets & JSP. (2nd edition, pg 80)
I'm getting stuck on the import of the javax and java.io classes. Where should these (jar?) file exist? 3 Replies
Your question is difficult to answer because I don't use NetBeans. There must be some way to configure NetBeans to know about the javax.??? and (certainly) java.io packages, but you will have to do that research yourself.
The Head First Servlets and JSP book was written to be independent of any IDE. You should be able to build this webapp using just a text editor and the Java command-line tools. Now, the *location* of the java.io package should be in a JAR file located in the 'jre' directory where you installed Java. The javax.??? packages exist wherever you deployed them. There are hundreds of these "standard extension" packages so it largely depends upon what you have installed. If you installed Tomcat then you will have access to at least the javax.servlet (with JSP-related subpackages) within the library directories where you installed Tomcat. This directory changes from time-to-time so I cannot give you a more definite answer to that either. Ah the joys of Java development. Sorry that I wasn't more help. Good luck, Bryan Basham
Comment by
DHVelocity
: Jun 09 2010 01:30 PM
Hi Bryan,
Thanks for the reply - I really appreciate it especially about your book! That is some special support! I am still not finding the files (java.io or the .jar) but I am more confident that I'll track them down and get them into my CLASSPATH. PS- I'm assuming that if I refer to the directories that contain these files they will be picked up by javac. My %CLASSPATH% is as follows, .;C:\Program Files\Java\jdk1.6.0_16\lib;C:\Sun\SDK\l6\lib;C:\Program Files\Java\jre6\lib\ext\QTJava.zip PS- The book is well written and it has been very informative. I'm going through the examples to be sure I learn everything being presented. Thanks again for your thoughts and for writing the book!
Hello DH,
Well, looking at your CLASSPATH one thing I need to point out is that you cannot just include the 'XYZ/lib/' directory of JAR files. You must include each individual JAR file on the CLASSPATH; like this: C:\Sun\SDK\l6\lib\servlet-api.jar;C:\Sun\SDK\l6\lib\jsp-api.jar;... and so on ... Does that make sense? BTW, I usually use Ant or a shell script to hide all of the complexity of the CLASSPATH. Especially if you have multiple projects using different class paths for compilation and execution. My recommendation is to use Ant. It is a relatively simple build (and execution) tool and the organization you will learn using Ant will help you understand richer build tools such as Maven and Hudson. Contact me in a private message if you want to know more about Ant. Happy coding, Bryan |
|||
|