Patrick Smith

Ranch Hand
+ Follow
since Oct 08, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Patrick Smith

It works now. I've tried lots of Classpaths, the lastz one worked and looks like this:
"set CLASSPATH=.;C:\;C:\Program Files\Tomcat\common\lib\servlet-api.jar;C:\DevEnv;C:\DevEnv\beerV1\classes\com\example\model;classes"
A soon as i leave thge last one ("classes") away, it can't find that package anymore. What is the meaning of that classpath extension? My problem is solved, but no idea why. And thats no good feeling....
Regrads, thanks for feedback on how to solve this in a controlled way.
15 years ago
I've tried it all out, no change. So i give you all transparently::
in a: the code of file BeerExpert.java, located in C:\DevEnv\beerV1\classes\com\example\web,
in b: the code of file BeerSelect.java, located in C:\DevEnv\beerV1\classes\com\example\model,
in c: the javac output when compiling file "BeerSelect.java" from C:\DevEnv\beerV1>
in d: the set of the classpath (in Windows XPSP2)

a)code of file BeerExpert.java (the compilation here works fine):
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;
}
}

b)code of file BeerSelect.java (the compilation here fails, see ouput below):
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class BeerSelect extends HttpServlet {
public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");
String c =request.getParameter("color");
BeerExpert a =new BeerExpert();
List result =a.getBrands(c);
Iterator it = result.iterator();
while(it.hasNext()) {
out.print("<br>try:"+it.next());
}
}
}

c) compiler output:
C:\DevEnv\beerV1>javac -d classes src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert a = new BeerExpert();
^
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert a = new BeerExpert();
^
3 errors

C:\DevEnv\beerV1>javac -d classes src/com/example/web/BeerSelect.java
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert a = new BeerExpert();
^
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert a = new BeerExpert();
^
3 errors

d) classpath set in the system variables screen: "C:\Program Files\Tomcat\common\lib\servlet-api.jar; C:\DevEnv\beerV1\src; C:\DevEnv\beerV1\classes;"
15 years ago
the extensions are ok, but i think there's a problem with the classpath, as it can't find the package. If i have the following situation:
file a is in: webapps/app_name/src/test/model/a.java
file b is in: webapps/app_name/src/test/web/b.java
I compile file a:
webapps/app_name>javac -d classes src/test/model/a.java -> all ok, a.class gets created in webapps/app_name/classes/test/model/a.class
I compile file b, that imports file a (import test.model.a.* ->
javac says:
"src/com/example/web/BeerSelect.java:3: package test.model does not exist"
The question is wether the classpath needs to be set specifically for those files below the webapps directory or does it find it automatically?
15 years ago
Hi,

My WebApp in the development phase looks like the following:
- a model file: webappname/src/com/example/model/BeerExpert.html. It has a package declaration that is "package com.example.model;"
- a view file: webappname/src/com/example/web/BeerSelect.html. It has a package declaration that is "package com.example.web;". That file imports the model file with the following command: "import com.example.model.*;"
When i compile the model file from webappname, all ok. But then,. when i compile the view file from webappname, it says:
"
src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
"

Any advice? Thanks for your help, Patrick
15 years ago
Thanks, that's it.
I thought that Java knows about Tomcat's jar files, but apperently not.
Regards, Patrick
15 years ago
Hi,
when trying to compile my first web app, i get the error message displayed below.
I have Windows XPSP2 & JDK 1.5.0_16.
The JAVA_HOME is set to the JDK directory (without including the bin directory). No Classpath variable is set.
Thanks for your help, Patrick

>javac -d classes src/com/example/web/Beerselect.java
src/com/example/web/Beerselect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/Beerselect.java:4: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src/com/example/web/Beerselect.java:7: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
src/com/example/web/Beerselect.java:8: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse resp
onse)
^
src/com/example/web/Beerselect.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect
public void doPost (HttpServletRequest request, HttpServletResponse resp
onse)
^
src/com/example/web/Beerselect.java:9: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect
throws IOException, ServletException {response.setContentType("t
ext/html");
^
6 errors
15 years ago
I'll check with the vendors and see where i go from there.
16 years ago
Hi,
i want to look at the javax.telephony classes, but i can't find it in the API. There's a download available on JTAPI, but it doesn't seem to be near as practical as the online API.
Any idea where i can get to that?
Thanks, Patrick
16 years ago
Hi,
is there a specific reason why there is no javax.telephony:* class listed in the JAVA API (SE & EE)?
Thanks, Patrick
16 years ago
that says it all, thanks again.
16 years ago
HI,
great, i've taken away all the uneeded an here's the smallest line that works:

"C:\Program Files\apache-tomcat-6.0.14\lib\servlet-api.jar; C:\WebAppsDev\beerV1\classes"

There's omne question left as the book indicates sth. bizarre to me. Here's the command (the "..." is up to each's own directory structure up to the Tomcat home directory):
"javac -classpath /..../tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/Beerselect.java"

What does the ":classes:." mean? When i try that, it just gives errors. And what does the "classes" behind "-d" mean?

But anyhow, it all works, this is just for a deeper understanding. I thank ou greatly for your efficient help.

Kind regards, Patrick
16 years ago
Ok, i'm getting closer.
When i enter the command you gave me, javac can't find the servlet-api.jar file, as my environment variables get overwritten.
Therefore, i've entered the command below (see between ***) and then compiled. It worked, but i have one question left: what does the last path mean ("classes")? It must be relative to where i start the javac from, as the C:.... path is not indicated. Can you explain or give me a ink where i can read that?
Kind regards, Patrick SAAR


""
set CLASSPATH=
.;
C:\Program Files\Java\jre1.6.0_01\lib\ext\QTJava.zip;
C:\Program Files\apache-tomcat-6.0.14\lib\servlet-api.jar;
C:\Program Files\Java\jdk1.6.0_04;
C:\WebappsDev;
C:\WebAppsDev\beerV1\classes\com\example\model;
classes
""

Then, i enter the following to compile Beerselect.java and javac replies the following:

C:\WebAppsDev\beerV1>javac -d classes src/com/example/web/Beerselect.java
src\com\example\web\Beerselect.java:3: package com.example.model does not exist

I've tried your proposal to enter the following, but then it can even not find servlet-api.jar and gives lots of other errors, but the error above is gone! How to proceed? Hall i add something to my "set CLASSPATH" command?
16 years ago
Hi,
i have a simple webapp in the developperphase (as given in the book "Head First Servlets & JSP"). I have installed jdk 1.6.0.4 and jre 1.6.0.4 (public). And i have Tomcat 6.0.14 up and running.
Now, i want to compile a servlet (see code at the end between "***") but the "import" command doesn't work, as it can't find the path. Here's the message by javac:
"C:\WebAppsDev\beerV1>javac -d classes src/com/example/web/beerselect.java
src\com\example\web\beerselect.java:3: package com.example.model does not exist
import com.example.model.*;
^
1 error"
.

I have set the JAVA_HOME variable (Windows XP SP2) in the systemvariables and in the uservariables the following way: C:\Program Files\Java\jdk1.6.0_04

I am about to troubleshoot this for weeks, i can't get the thing running, thanks for a feedback,
Patrick

Servlet code:

***
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class BeerSelect extends HttpServlet {

public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection advice <br>");
String c = request.getParameter("color");

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
Iterator it = result.iterator();
while (it.hasNext())
{
out.print("<br>try: " + it.next());
}
}
}
***
16 years ago
Hi,
i've reinstalled QuickTime and the warning is gone. No idea why.
The reason i posted this issue is because i have a more severe problem that i'll open in another topic.
Thanks for the feedback, Patrick.
16 years ago
Hello,
i have just implemented the latest version of JDK (6.0.4). When i compile a simple Java code, with the option "-Xlint", the compiler puts out the following warning:


C:\WebAppsDev\beerV1>javac -Xlint -d classes src/com/example/web/BeerSelect.java

warning: [path] bad path element "C:\Program Files\Java\jre1.6.0_01\lib\ext\QTJava.zip": no such file or directory

Can somebody tell me what this means? When googeling i found that QT is linked to QuickTime. I have that indeed on my PC but why is it involved when i launch javac??? By the way, this directory path does not exist as i have 6.0.4 running and the file QTJava.zip does not exist anywhere on my machine.
Thanks
16 years ago