• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

chapter 3 "mini MVC"

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes yes this exist on the physical memory & even the class too exist
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
That new kid is a freak. Show him this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic