Results 1 to 3 of 3
- 09-27-2009, 04:59 PM #1Member
- Join Date
- Sep 2009
- Rep Power
package javax.servlet does not exist :>
I put this here instead of netbeans section since it seems tob more relevant here.
you've read it once you've read it a thousand times! probably responded to it just as many times. Now i ask that you respond one more time
I've added as many details as possible becuase i've tried the solutions in an old thread in this forum but no luck.
h---ttp://developers.sun.com/mobility/midp/articles/tutorial2 <= I'm following what they're telling me to do step by step but i get JAVAC NOT RECOGNIZED when i try to compile the code from that website. It's called Writing Servlet Source Code
1- I downloaded TOMACAT zip and unzipped it in my C drive => C:\jakarta-tomacat-4.1.31 Contents of hte zip are inside this directory.
2- I went here C:\jakarta-tomacat-4.1.31\webapps\midp\WEB-INF\classes and put a copy of that java file here. I created the directory midp and its subdirectories.
3- I went to C:\jakarta-tomacat-4.1.31\bin and pressed STARTUP. Now the server is running.
4- I started a prompt and did as I was told where i set the path then i tried JAVAC and i failed.
5- I went to ENV vars. There was no classpath. So i created one and added its value as C:\jakarta-tomacat-4.1.31\common\lib\servlet.jar
6- I closed the prompt and the server then tried again. Failed.
7- I tried going to the directory where my java file was and then tried javac and still i failed.
8- I started NetBeans and checked plugins. To my luck, and surprise, i found tomacat plugin which I installed alongside another plugin called WebSomething. It says that this plugin will be installed as well since its dependant on it.
9- I went to TOOLS then OPTIONS then MISCLANEOUS and pressed ADD JAR/ZIP next CLASSPATH and put this C:\jakarta-tomacat-4.1.31\common\lib\servlet.jar
10- I started a new prj and created a java file with the same name as the one in the site. I copied hte code too. Red lines appeared on almost every line of code. Like import javax.servlet.http.*; was underlined and the tip said package javax.servlet does not exist
So what now? I tried to make my post as detailed as possible. If you have a solution plz let me no. and in details if you plz :D
My jdk directory is C:\Program Files\Java\jdk1.6.0
- 10-30-2009, 08:07 AM #2
try editing the environment variables (cotnrol panel > system > advanced > environment variables.
on the system variables add a variable JAVA_HOME and have it point to the JDK location.
its kind of unknown to me why windows, having the JDK folder on the PATH even, it will find Java, and it will find javac if you type it on the command line, but some things (like tomcat) that try to invoke javac from inside them, bust if JAVA_HOME sytem environment variable is not set (to C:\Program Files\Java\jdk1.6.0 in this case)
tomcat 4 is pretty ancient. are you sure you can't use tomcat 6 ? (the current version).
I remember some problems with tomcat4 and the Jasper (JSP) compiler, requiring a JDK (not a JRE), by default most modern tomcats and even IDEs run on a JRE (e.g. no javac command in the JRE). but the old tomcat needed to run on a JDK.
I think tomcat 6 uses an Ant or Eclipse JDT compiler for JSP pages, so it would likely just work in your setup. where tomcat 4 isn.t
- 02-17-2010, 12:02 AM #3Member
- Join Date
- Feb 2010
- Rep Power
hllo i'm new in this forum this is my first post
i don't know if your problem like i had too first i star programing in j2ee that problem is appear and i luck i found the solution
i set my PATH for the jdk C:\Program Files\Java\jdk1.6.0 \bin (cek if your in bin too cuz the class are in bin)
this is just for the class for j2SE
if you create project that extends HttpServlet in normal compile (cmd) the class will not found cuz it not in the C:\Program Files\Java\jdk1.6.0\bin so you must to add the classpath for compile in tomcat = c:\Apache Tomcat\lib\servlet-api.jar (just foundservlet-api.jar)
so the command line is
javac -classpath "c:\Apache Tomcat\lib\servlet-api.jar" yourfile.java
- By sknn in forum NetBeansReplies: 12Last Post: 02-03-2010, 03:14 PM
- By nikhil2jan in forum Java ServletReplies: 1Last Post: 01-04-2009, 04:32 PM
- By PzK in forum New To JavaReplies: 8Last Post: 12-03-2008, 10:30 PM
- By remya_srinivasan in forum Advanced JavaReplies: 1Last Post: 01-15-2008, 07:06 PM
- By osval in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 03:47 PM