File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chapter 3 "mini MVC"

 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ranchers I know you wonder why i am creating a new thread even though this question has been answered multiple times in multiple posts....but that posts doesnt worked for me or i am not getting the terminology..

my question is...
I am not able to compile the second version of the servlet on page no:84. the command i am using and the errors i got are here:

D:\MyProjects\beerV1>javac -d classes src/com/example/web/BeerSelecrt.java
javac: file not found: src\com\example\web\BeerSelecrt.java
Usage: javac <options> <source files>
use -help for a list of possible options

D:\MyProjects\beerV1>javac -d classes src/com/example/web/BeerSelect.java
src\com\example\web\BeerSelect.java:3: cannot find symbol
symbol : class model
location: package com.example
import com.example.model;
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src\com\example\web\BeerSelect.java:13: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
I am sure that there is nothing wrong in the code... The postings I read gave me a common solution that "You have to include the "com" directory in your classpath" but I am not even using the "-classpath" while compiling the code. Why to do this & how to do this to resolve this problem since I have already created the classpath in the enviroment variable.. I have reached till this part i.e. my previous coding & paths are right so what is the problem right now? Please help me.
Thanks in advnnce
Here is my directory sructure:
D:\MyProjects\beerV1\src\com\example\web\BeerSelect.java

C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib\servlet-api.jar-this path is kept in the classpath enviroment variable
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D:\MyProjects\beerV1>javac -d classes src/com/example/web/BeerSelecrt.java
javac: file not found: src\com\example\web\BeerSelecrt.java
Usage: javac <options> <source files>
use -help for a list of possible options

SORRY This is not the part of the latest error..This is the previous error that i pasted in notepad
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rakesh kadulkar welcome to Javaranch ,

import com.example.model;

does the above package exists along with the model class in it.
And there is nothing written before the import statement.


Hope this helps
 
Praveen Shivashankar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing the same problem too. The Earlier Model class, compiled successfully..or atleast it didn't throw any errors when it ran the javac -d classes src/com/example/model/BeerExpert.java command. But I am not able to see the .class file at the specified location.

The recompilation of the Servlet is throwing the same errors that has been reported. Can anyone please throw some more light on this?!!
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes yes this exist on the physical memory & even the class too exist
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rakesh kadulkar.

Two things.

1.) When asking a question about a particular book, it's always a good idea to tell us what the title of the book is. In this case, I'm assuming it's Head First Servlets and JSP. It's better not to assume that everyone here will already know this.

2.) The best place to ask questions about compiling Java classes (including servlets) is our Java In General (Beginner forum). We have a FAQ entry that discusses compiling servlets here. See if it helps. I'll move this to the other forum for you.
 
Praveen Shivashankar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello... here is the specific commands and the corresponding programs that am trying to run

Model:

package com.example.model;
import java.util.*;

public class BeerExpert {

public List getBrands(String color){
List brands = new ArrayList();
if(color.equals("amber")){
brands.add("Jack Amber");
brands.add("Red Moose");
}
else{
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return (brands);
}

}


The corresponding command is:

C:\Users\Praveen\workspace\beerV1>javac -d classes src/com/example/model/BeerExp
ert.java

This command seems to compile without any errors. But I don't see a class file being created.


The modified servlet program is being compiled with the following command:

C:\Users\Praveen\workspace\beerV1>javac -classpath "C:\Program Files\Apache Soft
ware Foundation\Tomcat 5.0\common\lib\servlet-api.jar" -d classes src\com\exampl
e\web\BeerSelect.java

The corresponding errors am getting is:


src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:16: cannot resolve symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src\com\example\web\BeerSelect.java:16: cannot resolve symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();

Am being held up due to this issue.. can someone puhleeezzzzz sort this out?!! thanks guys!!
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was simple I sm suppose to include the package in my classpath...

Here is the command that i used..
D:\MyProjects\beerV1>javac -classpath "C:\tomcat\Tomcat 5.5\common\lib\servlet-a
pi.jar;d:\myprojects\beerv1\classes" -d classes src/com/example/web/BeerSelect.j
ava

Note:- The " " are compulsory.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47286
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out. The reason you need "" is because there is a space in the quoted classpath.
 
Praveen Shivashankar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey.. am still not able to.. and I've used the appropriate "" too!! The class file for the BeerExpert.java is not to be found either!! This is driving me nuts!! Sighhh
 
Praveen Shivashankar
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys!.. never mind!! Got it!! It was a stupid.. pesky lil : instead of ; DUHHHH!!! Gosh!! makes me wanna do things to this.. Arrrghhhh
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic