Anupam Dev wrote:what error do you get? kingly copy paste the error you are getting...
Anupam Dev wrote:i think you should rename your WEB_INF directory to WEB-INF.
The folder where my project is ServletsFolder whose path is---
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Myk Romo wrote:Hi,
can you post here the exact code of your servlet?
Tips:
- make sure the specified package is exist.
- and make sure the class that you've instantiate is on the package..
Vijitha Kumara wrote:Welcome to CodeRanch, J Das!
Looks like the compiler cannot find the Java class. Add a classpath entry to contain the path to the Java class "CoffeeExpert". (e.g.: javac -cp <PathToClass & servlet jar> <SourceFiles>). You may want to check our faq entry: HowToSetTheClasspath.
The folder where my project is ServletsFolder whose path is---
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder
Never put your working folders inside the server instance. Use another directory in your home directory for development, then you may build and deploy to the server.
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:Since you already have set the CLASSPATH to servlet-api.jar you can append the new entry while compiling the source.
javac -cp %CLASSPATH%;<PathToTheClass> <SourceFiles>
Replace the "<PathToTheClass>" with the path to your compiled POJO class. It should be to the directory where your package folder exists. (I guess I got it right in the path separator for entries in Windows, if not try ":" instead ";" to separate the entries.)
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:You have to escape the spaces in the directory path. Use quotes to wrap the path and see.
Try this to compile if you need it in this way:
javac -cp %CLASSPATH%;"C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\" "C:\Program
Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WE
B-INF\classes\com\example\web\CoffeeSelect.java"
BTW, you can try what I said before also: cd to classes directory and ....
Anupam Dev wrote:@J Das
It's for sure, you have a classpath problem...
the error says it can't find the package
coffeeselect.java:2: package com.example.model does not exist
so first of all goto the web-inf/classes directory and list the contents (the java file names) and check whether in each java file you have used the proper package statements in each file.....
Anupam Dev wrote:@J Das
It's for sure, you have a classpath problem...
the error says it can't find the package
coffeeselect.java:2: package com.example.model does not exist
so first of all goto the web-inf/classes directory and list the contents (the java file names) and check whether in each java file you have used the proper package statements in each file.....
Anupam Dev wrote:List the contents of CoffeeExpert.java. The problem is in this file i think...
Anupam Dev wrote:ha ha got the culprit.....
you have to write
package com.example.web
Does this solve your problem???
Anupam Dev wrote:ha ha got the culprit.....
you have to write
package com.example.web
Does this solve your problem???
Anupam Dev wrote:refer to this page
https://coderanch.com/t/453337/java/java/Invalid-Flag-Error-when-javac
Bear Bibeault wrote:This has nothing to do with servlets but with learning how to compile from the command line, so it has been moved to a more appropriate location.
Anupam Dev wrote:Use this
C:\>javac -cp "C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\" "C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\com\example\web\CoffeeSelect.java"
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:Try this:
javac -cp %CLASSPATH%;"C:\Program Files\Apache Software Foundation1\Apache T
omcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes" "C:\Program Files\Apache S
oftware Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\
com\example\web\CoffeeSelect.java"
It's probably the trailing slash in -cp entry causing the issue...
J Das wrote:
Anupam Dev wrote:what error do you get? kingly copy paste the error you are getting...
this is my command screen with compilation errors >>>>
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Jyotirmoy>cd C:\Program Files\Apache Software Foundati
on1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes\com\example\web
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\Servle
tsFolder\WEB-INF\classes\com\example\web>javac coffeeselect.java
coffeeselect.java:2: package com.example.model does not exist
import com.example.model.*;
^
coffeeselect.java:19: cannot find symbol
symbol : class CoffeeExpert
location: class com.example.web.CoffeeSelect
CoffeeExpert ce = new CoffeeExpert();
^
coffeeselect.java:19: cannot find symbol
symbol : class CoffeeExpert
location: class com.example.web.CoffeeSelect
CoffeeExpert ce = new CoffeeExpert();
^
3 errors
as i am new to this things so i may be wrong in the compilation process (i guess)... and by the way , thanks Anupam for your quick view to my problem... please rply this to me now what should i do...![]()
![]()
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sakthi Sivram wrote:
Try this one,
From command prompt go to the path,
C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\ServletsFolder\WEB-INF\classes>
Then set classpath like below,
set CLASSPATH=%CLASSPATH%;C:\Program Files\Apache Software Foundation1\Apache Tomcat 6.0.26\webapps\Servle
tsFolder\WEB-INF\classes;
Then compile your servletcode like,
javac com/example/web/CoffeeSelect.java
The problem is "CoffeeSelect" cannot able to find the class file "CoffeeExpert" since you are compiling from "CoffeeSelect" path. Refer your code above.
Vijitha Kumara wrote:Welcome to CodeRanch, Sakthi Sivram!
The latest problem the OP facing is that the command line does not interpret the arguments to javac properly.
@J Das
At this point you can try two things.
1. Add the entry for the compiled POJO class in to the CLASSPATH environment
variable, and try compiling.
2. Go to the .../WEB-INF/classes directory and try compiling as I said before.
(Note: You can avoid most of these problems by using a seperate path for your development work.)
Vijitha Kumara wrote:(Note: You can avoid most of these problems by using a seperate path for your development work.)
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?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |