aspose file tools*
The moose likes Beginning Java and the fly likes chapter 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "chapter 3 "mini MVC"" Watch "chapter 3 "mini MVC"" New topic
Author

chapter 3 "mini MVC"

rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
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
rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

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


SCJP, SCWCD.
|Asking Good Questions|
Praveen Shivashankar
Greenhorn

Joined: Jul 20, 2008
Posts: 13
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?!!


I like talking to myself, coz I always hear what I like!
rakesh kadulkar
Ranch Hand

Joined: Jul 24, 2008
Posts: 115
yes yes this exist on the physical memory & even the class too exist
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Praveen Shivashankar
Greenhorn

Joined: Jul 20, 2008
Posts: 13
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

Joined: Jul 24, 2008
Posts: 115
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

Joined: Oct 13, 2005
Posts: 39409
    
  28
Well done sorting it out. The reason you need "" is because there is a space in the quoted classpath.
Praveen Shivashankar
Greenhorn

Joined: Jul 20, 2008
Posts: 13
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

Joined: Jul 20, 2008
Posts: 13
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
 
subject: chapter 3 "mini MVC"