Help ~~ Cannot compile servlet program
I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
package javax.servlet does not exist
I've download the class files and set the classpath already. Have I missed anything?
Thx!
I have recently written a servlet program. When I
compile the program (let's say "HelloWorld.java"),
I've got the following error message:
package javax.servlet does not existyou donot have servlet api classes in your classpath
I've download the class files and set the classpath
already. Have I missed anything?just check the classpath again and compile.
say echo CLASSPATH and see
Similar Messages
-
Cannot compile servlet program
I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
package javax.servlet does not exist
I've download the class files and set the classpath already. Have I missed anything?
Thx! ^-^Maybe you should listen in at
http://forum.java.sun.com/thread.jsp?forum=45&thread=234654
He has a similar problem.
Did you put the servlet.jar in your classpath? -
I cannot compile Servlet files on my WinXP environment.
my servlet.jar file is located at
c:\tomcat\jakarta-tomcat-3.3.1\common\lib\servlet.jar
what shall I do?
The error messages are only for servlet portion of code?In XP you can set the path by rightclicking on my computer - then go to environment vairables and edit the path but I cannot see any for classpath???
What is the easist way yo use the class path? -
I have jsdk2, but I can't compile servlet program
I have jsdk2 version. which create in my c:\ dirve a folder jdk1.3. I do all the program from that. But I found that some of the class files of Servlet (servletRespose etc ) is missing. What I do to recover that. Even I can't compile any servlet program from that. Pls reply to my problems.
Regards.
RanjanThe Servlet API is part of J2EE (Java 2 Enterprise Edition). It is not included in the Standard Edition.
So you need to download and install the J2EE reference implementation or another servlet engine such as Apache Tomcat ( http://jakarta.apache.org/tomcat ). Don't forget to put the Tomcat JAR files in your CLASSPATH when compiling your servlet program.
Jesper -
Can't compile Servlet program(error in setting classpath in XP)
I encountered a similar problem as 'hereispaddy'.
"I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
package javax.servlet does not exist
I've download the class files and set the classpath already. Have I missed anything? "
i would like to ask, how to set the following in Windows XP:
set CATALINE_HOME=C:\PROGRA~1\APACHE~1.0
set CLASSPATH=.;%CATALINE_HOME%\COMMON\LIB\SERVLET.JAR;C:\JDK1.4\BIN;
*ive tried in control panel->system->advanced->environment variables->
variable name:CATALINE_HOME
variable value:C:\Program Files\Apache Tomcat4.0 (and)
variable name:CLASSPATH
variable value:.;%CATALINE_HOME%\common\lib\servlet.jar;C:\jdk1.4\bin
but failed!
Could anyone kindly tell me what's wrong with my setting?
Thx a lot!!!Does Tomcat work? Can run the examples on the home page?
The only suggestion I have at this point is to get rid of the spaces in
C:\Program Files\Apache Tomcat4.0
But I am still in Win98 , so I am just guessing. -
HELP for Compile java programe !
Hello All,
i want to make java programe by which i can compile java programes
and when i compile java programe from my programe then
i shoul get compiled status means programe compile successfuly
or not compile.
if any example i m thanksfull.
onlyforjava.how about if compile fail?
the process obj seems return value 0 as it run successful.
I haven't try this, but I have experienced the process obj returns 0 if the executed command has some routine to handle error cases, in which, error will not halt the system.
So, I recommand the following scenario.
1. let say, if your java is test.java. check the existence of file test.class.
If, it exists, get its modified time.
2. compile the java code with
Procress p = Runtime.exec(new String[]{"javac", "test.java"});
3. get the error string if any.
InputStream in = new BufferedInputStream(p.getInputStream());int read;while ((read = in.read()) != -1){ System.out.println((char)read);}
4. handle error with the exitValue
if (p.exitValue() != 0){ System.out.println("warning.");}
5. check again the file test.class if it is a newly created file.
6. if it is newly created, compile success. Else, failed. -
hi everyone,
when i tried to compile a java Program i had created.I got the following Error.
Error occoured during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
I reinstalled the entire thing from the system and when i tried to compile the java Program again it gives like a 1000 errors even on the programs i know that work fine and even the very basic 5 or 10 line Programs.Can someone tell me what is happening??Having Deleted a file in the folder that i was executing the javac seem to have fixed the problem.It was called String.java
and the content of the file were as mentioned under:Any help on why it happened or what the file was doing would be really appreciated.
The content of the file:-
""Java String Examples
The String class implements immutable character strings, which are read-only once the string object has been created and initialized. All string literals in Java programs, are implemented as instances of String class.
The easiest way to create a Java String object is using a string literal:
1.
String str1 = "I can't be changed once created!";
A Java string literal is a reference to a String object. Since a String literal is a reference, it can be manipulated like any other String reference. i.e. it can be used to invoke methods of String class.
For example,
1.
int myLenght = "Hello world".length();
The Java language provides special support for the string concatenation operator (+), which has been overloaded for Java Strings objects. String concatenation is implemented through the StringBuffer class and its append method.
For example,
1.
String finalString = "Hello" + "World";
Would be executed as
1.
String finalString = new StringBuffer().append("Hello").append("World").toString();
The Java compiler optimizes handling of string literals. Only one String object is shared by all strings having same character sequence. Such strings are said to be interned, meaning that they share a unique String object. The Java String class maintains a private pool where such strings are interned.
For example,
1.
String str1="Hello";
2.
String str2="Hello";
3.
If(str1 == str2)
4.
System.out.println("Equal");
Would print Equal when executed.
Since the Java String objects are immutable, any operation performed on one String reference will never have any effect on other references denoting the same object.
String Constructors
String class provides various types of constructors to create String objects. Some of them are,
String()
Creates a new String object whose content is empty i.e. "".
String(String s)
Creates a new String object whose content is same as the String object passed as an argument.
Note: Invoking String constructor creates a new string object, means it does not intern the String. Interned String object reference can be obtained by using intern() method of the String class.
String also provides constructors that take byte and char array as an argument and returns String object.
String equality - Compare Java String
String class overrides the equals() method of the Object class. It compares the content of the two string object and returns the boolean value accordingly.
For example,
1.
String str1="Hello";
2.
String str2="Hello";
3.
String str3=new String("Hello") //Using constructor.
4.
5.
If(str1 == str2)
6.
System.out.println("Equal 1");
7.
Else
8.
System.out.println("Not Equal 1");
9.
10.
If(str1 == str3)
11.
System.out.println("Equal 2");
12.
Else
13.
System.out.println("I am constructed using constructor, hence not interned");
14.
15.
If( str1.equals(str3) )
16.
System.out.println("Equal 3");
17.
Else
18.
System.out.println("Not Equal 3");
The output would be,
Equal 1
Not Equal 2
Equal 3
Note that == compares the references not the actual contents of the String object; Where as equals method compares actual contents of two String objects.
String class also provides another method equalsIgnoreCase() which ignores the case of contents while comparing.
Apart from these methods String class also provides compareTo methods.
int compareTo(String str2)
This method compares two Strings and returns an int value. It returns
- value 0, if this string is equal to the string argument
- a value less than 0, if this string is less than the string argument
- a value greater than 0, if this string is greater than the string argument
int compareTo(Object object)
This method behaves exactly like the first method if the argument object is actually a String object; otherwise, it throws a ClassCastException."""
Edited by: Gold_y on Oct 30, 2009 4:59 AM -
I have this in my classpath
set classpath=.e:/tomcat/Tomcat-5/common/lib/servlet-api.jar;.e:/tomcat/Tomcat-5/common/lib/jsp-api.jar
but I still get those errors saying import java.servlet.*; error
let me know what could be worng
asYou seem to have ".e:\" (ie DOT e:\) twice in your classpath
You want DOT as a classpath directory in its own right
Try this maybe
set classpath/T=.;e:/tomcat/Tomcat-5/common/lib/servlet-api.jar;e:/tomcatomcat-5/common/lib/jsp-api.jar
What are you using to compile the servlets with?
With the command line try including the classpath as an argument:
ie javac -classpath .;e:/tomcat/Tomcat-5/common/lib/servlet-api.jar;e:/tomcatomcat-5/common/lib/jsp-api.jar *.java
If you are using an IDE like Eclipse/Netbeans, you need to look at your project settings to set the library path.
Cheers,
evnafets -
Hi,
I have written a project.
it has three packagess model,view,controller.
i.e we have folders like
C:\exercise1\model\view\controller.
and a main file
C:\exercise1\mortgagecalculator.
when i run the project in eclispe workspace it runs fine but when i run this at command prompt it gives me error that import statements in C:\mortgagecalculator are not working.
even import in
C:\model\view
and
C:\model\view\Controller are also not working
the classpath has been set to C:\exercise1
and path="C:\programfiles\java\jdk1.5._02\bin"
please help me in this regard.
Regards,
mallikThe fact that you have a \model\view directory listed both under filesystem root and under \exercise1, and that you spell "controller" also as "Controller", and that you have a directory \model\view\controller when the paradigm really suggests that they should be three parallel, not nested, directories, suggests to me that your code is randomly thrown around or that you're not referring to your packages consistently, or both.
It's hard to say exactly what you've done wrong, since you didn't go into a lot of detail about the error messages.
So just try to be consistent and formal about where you keep your source code and your compiled classes and how you invoke javac. -
Please help - cannot open cs6 programs
I signed up for CC today. Already had many Adobe cs3 and cs6 programs on my laptop. Mac Powerbook OS 10.8.4.
Installed CC desktop, photoshop, dreamweaver.
Now I can't open any adobe software. I keep getting error 16 to uninstall and reinstall the program.
I tried removing cc desktop, downloader, cc dreamweaver and photoshop and reinstalling my cs6 programs.
Nothing works. I can't get any work done because I can't open any programs.
I did try the fix below. It does not work.
http://helpx.adobe.com/x-productkb/policy-pricing/configuration-error-cs5.htmlFixe the user permissions:
Enabling and using the "root" user in Mac OS X
Security Stuff
Mylenium -
Problem in compiling aa servlet program
I have installed jsdk1.4.2_13
And also installed tomcat 5.0.28
I have set
CATALINA_HOME==C:\Program Files\Tomcat\jakarta-tomcat-5.0.28
JAVA_HOME ==C:\j2sdk1.4.2_13
CLASS_PATH==
C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;
C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar
PATH ==C:\j2sdk1.4.2_13\bin;C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
-->My java programs are compiling
-->I can run tomcat server , And also can see starting page of "http://localhost:8080/"
But I am not able to compile servlet program
MY sevlet program is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello</H1>\n" +
"</BODY></HTML>");
ERRORS are:
Pakage javax.servlet does not exist
Pakage javax.servlet.http does not exist
cannot resolve symbol HttpServletRequest
and similar errors
can anyone guide me?
Message was edited by:
Learnit's not CLASS_PATH, it's CLASSPATH.
Directory paths with spaces in them are problematic. Surround them with double quotes.
I think the best thing is not a CLASSPATH environment variable. Better to use the -classpath option on javac.exe when you compile.
So your command to compile might look something like:
javac -classpath .;"C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar" *.java% -
Cannot compile with 1.2.2
On winnt, I cannot compile a program using JDK 1.2.2 and the oracle classes111.zip, either 8.05 or 8i(8.1.5). I get the ff sort of message:
The method oracle.jdbc2.Clob getClob(int) declared in oracle.jdbc.driver.OracleResultSet cannot override the method of the same signature declared in java.sql.ResultSet. They must have the same return type.
This same code will compile and runusing version jdk 1.17
Any help greatly apppreciated,
emcUse classes12.zip to compile with JDK 1.2.X
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ed Colgan ([email protected]):
On winnt, I cannot compile a program using JDK 1.2.2 and the oracle classes111.zip, either 8.05 or 8i(8.1.5). I get the ff sort of message:
The method oracle.jdbc2.Clob getClob(int) declared in oracle.jdbc.driver.OracleResultSet cannot override the method of the same signature declared in java.sql.ResultSet. They must have the same return type.
This same code will compile and runusing version jdk 1.17
Any help greatly apppreciated,
emc<HR></BLOCKQUOTE>
null -
Anyone can compile this program?Duke will be rewarded
Anyone can help me compile this program..I try debugging a lot of time but it is not working!
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class ChatApplet extends Applet implements ActionListener,Runnable
String user;
String msg;
public void init() {
super.init();
//{{INIT_CONTROLS
setLayout(new BorderLayout(0,0));
addNotify();
resize(518,347);
setBackground(new Color(12632256));
msgbox = new java.awt.TextArea("",2,0,TextArea.SCROLLBARS_NONE);
msgbox.setEditable(false);
msgbox.disable();
//msgbox.hide();
msgbox.reshape(0,0,380,216);
add(msgbox);
idbox = new java.awt.TextField();
idbox.reshape(84,288,284,24);
add(idbox);
button1 = new java.awt.Button("EnterRoom");
button1.reshape(384,288,72,21);
add(button1);
list = new java.awt.List();
//list.TOP_ALIGNMENT();
//list.disable();
list = new java.awt.List(5);
list.add("#Default User"+"\n");
list.reshape(384,24,128,196);
list.setFont(new Font("Helvetica", Font.BOLD, 12));
add(list);
label2 = new java.awt.Label("Members");
label2.reshape(396,0,100,19);
add(label2);
label1 = new java.awt.Label("UserName");
label1.reshape(0,288,72,27);
add(label1);
textbox = new java.awt.TextField();
textbox.reshape(84,240,431,44);
add(textbox);
label3 = new java.awt.Label("EnterText");
label3.reshape(0,252,72,25);
add(label3);
//uf = new UserFrame();
button1.addActionListener(this);
idbox.addActionListener(this);
textbox.addActionListener(this);
list.addActionListener(this);
public void actionPerformed(ActionEvent ae)
if(ae.getSource()==idbox)
user = idbox.getText()+"\n";
list.addItem(user.trim());
idbox.setText("");
msgbox.append(user+" HAS JOINED THE GROUP");
if(ae.getSource().equals(button1))
user = idbox.getText()+"\n";
list.addItem(user.trim());
idbox.setText("");
msgbox.append(user+" HAS JOINED THE GROUP");
if(ae.getSource().equals(textbox))
msg = textbox.getText();
msgbox.append(msg+"\n");
textbox.setText("");
if(ae.getSource().equals(list))
String l = list.getSelectedItem();
//uf.setTitle(l);
//Frame i[] = uf.getFrames();
//uf.setVisible(true);
public void start()
if(vt == null)
vt = new Thread(this,getClass().getName());
vt.start();
public void run()
try{
for(int i=0;i<10;i++)
msgbox.append("One stop Java source code - www.globalleafs.com"+"\n");
msgbox.setForeground(Color.red);
vt.sleep(30000);
vt.resume();
}catch(Exception e){e.printStackTrace();}
java.awt.TextArea msgbox;
java.awt.TextField idbox;
java.awt.Button button1;
java.awt.List list;
java.awt.Label label2;
java.awt.Label label1;
java.awt.TextField textbox;
java.awt.Label label3;
private Thread vt;The program compiles over here. It just has some deprecation warnings ...or is that what you wanted debugged?
Don't use reshape() ...I think in AWT you should now use setBounds();
Don't use list.addItem(); ...looks like the API steers us to list.add();
Don't use Thread.resume() ...I don't think there is a replacement (unneccessary?).
Gee, this program must have ran the chat program in Ford's old model T ... !! (??) -
Can't compile my first servlet program
hi guys,
there are some problems with compiling the first servlet program(helloservlet).
the error is following
C:\SERVLET-CODE\hello1>javac HelloServlet.java
HelloServlet.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
HelloServlet.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloServlet.java:15: cannot resolve symbol
symbol : class HttpServlet
location: class HelloServlet
public class HelloServlet extends HttpServlet {
^
HelloServlet.java:16: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloServlet
public void doGet(HttpServletRequest request,
^
HelloServlet.java:17: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloServlet
HttpServletResponse response)
^
HelloServlet.java:18: cannot resolve symbol
symbol : class ServletException
location: class HelloServlet
throws ServletException, IOException {
^
6 errors
i don't know why it can not find the import java.*
and i already set up the classpath
and my code is
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Simple servlet used to test server.
* <P>
* Taken from More Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.moreservlets.com/.
* © 2002 Marty Hall; may be freely used or adapted.
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello</H1>\n" +
"</BODY></HTML>");
please help me out of it...
thank you all...hi man,
thanks for the classpath, and i already did it in system environment.
but it can not work either...
do i really have to download the API, so where i have to put it after i download it... -
Please help me to use javamail to send mail in servlet program
hi
i want to send simple mail from user [email protected] to user [email protected] using servlet program
i can't compile the javamail demo program servlet "JavaMailServlet.java".
i have this exception
Note: SendMailServlet.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
i don't no how to do
please help me if you have code
thank'sGiven that you're having problems with your [url http://forum.java.sun.com/thread.jsp?forum=43&thread=536278&tstart=0&trange=30]demo mail code as well as your demo servlet code, perhaps you would be better served by learning about JavaMail, servlets, and perhaps Java in general (for example - the meaning of deprecated). Then you may be able to build your own servlet for handling mail or at least will be able to revise the demo code found elsewhere.
Of course, if the purpose is really not to learn how to use Java, JavaMail, servlets, etc. but to simply create something that works then you could always hire someone to write the program for you.
This is not intended to be rude or anything - just an observation and some food for thought.
∞ brewman ∞
Maybe you are looking for
-
when i try to instal itunes on pc i get this message. This installation pack could not be opened. Verify that package exists and that you can access it or contact application vendor to verify that this is a valid windows installation pack. PLEASE HEL
-
How do i use multiple threads( very much real time), using JavaFX?
I'm creating an application, using JavaFX because one can create awesome GUI using JavaFX. I need to know how to create real time multiple threads using javafx. JavaFX doesn't support creation of multiple threads, but i think there is another way of
-
So i got my offer for a free 1 month subscription the other day. I went to activate it and it ended up totally activated, but on skype nothing was working and the subscription wasnt active. Can anyone help?
-
I am trying to reinstall Photoshop 10 but keep getting error "2350.FDI server error" I'm not on a server. Can someone assist me on how to reinstall from original discs?
-
Hey guys, I have a concern and it is the CustomCatalog that we feel with our Internationlization messages. This is nice we have a one stop shop to place all of our custom messages, but here are some weaknesses. 1. Scalability. 2. Multiple Projects wo