Anupam Dee wrote:Try this first
make a directory in your d:/new folder (do not remove the space between new and folder)
and build the directory tree as follows
d:\new folder\com\web
d:\new folder\com\model
and then create two classes
d:\new folder\com\web\abc.java
d:\new folder\com\model\xyz.java
abc.java
----------
package com.web;
class abc
{
}
xyz.java
----------
package com.model;
import com.web.*;
class xyz
{
abc a=new abc();
}
and then compile using
c:\> javac -cp "d:\new folder" "d:\new folder\com\model\xyz.java"
does this compile on your system successfully?
Anupam Dee wrote:Try this first
make a directory in your d:/new folder (do not remove the space between new and folder)
and build the directory tree as follows
d:\new folder\com\web
d:\new folder\com\model
and then create two classes
d:\new folder\com\web\abc.java
d:\new folder\com\model\xyz.java
abc.java
----------
package com.web;
class abc
{
}
xyz.java
----------
package com.model;
import com.web.*;
class xyz
{
abc a=new abc();
}
and then compile using
c:\> javac -cp "d:\new folder" "d:\new folder\com\model\xyz.java"
does this compile on your system successfully?
Anupam Dee wrote:Try this first
make a directory in your d:/new folder (do not remove the space between new and folder)
and build the directory tree as follows
d:\new folder\com\web
d:\new folder\com\model
and then create two classes
d:\new folder\com\web\abc.java
d:\new folder\com\model\xyz.java
abc.java
----------
package com.web;
class abc
{
}
xyz.java
----------
package com.model;
import com.web.*;
class xyz
{
abc a=new abc();
}
and then compile using
c:\> javac -cp "d:\new folder" "d:\new folder\com\model\xyz.java"
does this compile on your system successfully?
J Das wrote:hello everyone...
![]()
i have just joined JAVARANCH today.. so in posting my queries if you find some syntactic errors please excuse me.... recently i have been following the Head First Servlets and JSP book for beginning with some web app.. the problem i am facing is in compiling the second version of the servlet program thats been illustrated in chapter 3.... I am using Windows Xp , i have Tomcat version 6 installed on my system and also i have JDK 1.6.x installed... What i have done by far is this---->>>>
* The folder where my project is ServletsFolder whose path is---
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder
*Inside the folder (ServletsFolder) i have a WEB_INF folder and a html form named form.html
*The WEB_INF contains a deployment descriptor (web.xml) file and a folder named (classes).
*the classes folder contains (com\example\web) and (com\example\model) where the web folder contains the servlet (CoffeeSelect.java) and the model folder contains the plain java class(CoffeeExpert.java) whom the servlet invokes.
the situation so far.... when i compile the plain java (CoffeeExpert.java), it gets compiled but the servlet doesn't compile![]()
... may be i am wrong in my compiling procedure because i am new to servlets and things like Classpath, setting Environment variables etc.. so can any one let me know the way this things should be done..??? please help me out i am stuck with this badly....
![]()
![]()
repi need this to be solved as soon as possible .. hoping to get quick replies ...
![]()
Campbell Ritchie wrote:The add call must be inside a method (or initialiser), not necessarily the main method.
Ashutosh Limaye wrote:
J Das wrote:hello everyone...
![]()
i have just joined JAVARANCH today.. so in posting my queries if you find some syntactic errors please excuse me.... recently i have been following the Head First Servlets and JSP book for beginning with some web app.. the problem i am facing is in compiling the second version of the servlet program thats been illustrated in chapter 3.... I am using Windows Xp , i have Tomcat version 6 installed on my system and also i have JDK 1.6.x installed... What i have done by far is this---->>>>
* The folder where my project is ServletsFolder whose path is---
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder
*Inside the folder (ServletsFolder) i have a WEB_INF folder and a html form named form.html
*The WEB_INF contains a deployment descriptor (web.xml) file and a folder named (classes).
*the classes folder contains (com\example\web) and (com\example\model) where the web folder contains the servlet (CoffeeSelect.java) and the model folder contains the plain java class(CoffeeExpert.java) whom the servlet invokes.
the situation so far.... when i compile the plain java (CoffeeExpert.java), it gets compiled but the servlet doesn't compile![]()
... may be i am wrong in my compiling procedure because i am new to servlets and things like Classpath, setting Environment variables etc.. so can any one let me know the way this things should be done..??? please help me out i am stuck with this badly....
![]()
![]()
repi need this to be solved as soon as possible .. hoping to get quick replies ...
![]()
If you are using tomcat add servlet-api.jar to the classpath before compiling the servlet java file.![]()
Anupam Dee wrote:i just can't understand...
i created the same scenario on my system...but i m able to compile it successfully....i have simply copy and pasted your code... and your javac commands and all that...
and it got compiled in one go...
i am not able to understand why is it so...
create two classes in the same web-inf\classes\com\web and model directories... let the package and import statements be as such... but create empty classes....no methods no variables nothing...even don't extend HttpServlet and then try to compile... still if you are getting errors then...google is the best option i think...
J Das wrote:I changed the CLASSPATH in my environment variable to the following...
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\com\example\model
and by the way what did you mean when you said
Vijitha Kumara wrote:
(Note: You can avoid most of these problems by using a separate path for your development work.)
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
. So I wanted to know exactly what is "-cp" and what was that "%CLASSPATH%;" thing all about.
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Using -cp switch would override any entries you have set in CLASSPATH environment variable. Including it along with -cp switch would append new entries to it so that javac/java etc... will pick them all.
Campbell Ritchie wrote:If you use
-cp c:\foo
means your entire classpath is the foo directory. You will even lose the . for current directory from the classpath.
If you use
-cp %CLASSPATH%;c:\foo
you are adding the foo directory to the end of the old classpath. The foo directory is now in addition to the old classpath.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |