Forums Register Login

Unable to compile Packge servlet

+Pie Number of slices to send: Send
Hi,
I have been trying to compile a package servlet,and i have also including my development directory path in the classpath.But its not working at all.Its giving the error to find out my model class package.I am writing the classpath below which i have been using to compile please tell me if its correct or not also how to compile otherwise.

set CLASSPATH=.;C\Program Files\...\Tomcat;MyProjects

where MyProjects is my development directory and is in C drive
+Pie Number of slices to send: Send

please post the compile error..

where MyProjects is my development directory and is in C drive



So the class path should include the top level of your servlet package. Use C:\MyProjects , and not MyProjects
+Pie Number of slices to send: Send
Hi The following is the error

C:\Users\Guest\Desktop>set path="C:\Program Files\Java\jdk1.5.0_17\bin";

C:\Users\Guest\Desktop>set CLASSPATH=.;C:\apache-tomcat-5.5.27\common\lib\servle
t-api.jar;MyProjects

C:\Users\Guest\Desktop>javac BeerSelect.java
BeerSelect.java:2: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors

C:\Users\Guest\Desktop>

+Pie Number of slices to send: Send
As said before, you need to specify absolute paths, not relative paths. "MyProjects" is a relative path and only relative to the current working directory. Replace it by an absolute path, e.g. "C:/MyProjects".
+Pie Number of slices to send: Send
I even tried it but the result is no different.

C:\Users\Guest\Desktop>set CLASSPATH=.;C:\apache-tomcat-5.5.27\common\lib\servle
t-api.jar;C:\MyProjects

C:\Users\Guest\Desktop>javac BeerSelect.java
BeerSelect.java:2: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors

I m afraid i m missing something in the dos command for CLASSPATH setting!!!
+Pie Number of slices to send: Send
Moving to Java in General where compiling issues are best dealt with.
+Pie Number of slices to send: Send
 

AsifAimen Iqbal wrote:
I m afraid i m missing something in the dos command for CLASSPATH setting!!!



Classpath is bit tricky when setting it in DOS/Windows. The problem occurs in case you have set an Environment Variable class 'classpath' and you are trying to re-define it in the dos window.

Here are couple of alternatives that might work.

1. Set the environment variable classpath --> Right Click my computer --> properties --> Advance --> Environment Variables --> Set the class Path to .;C:\apache-tomcat-5.5.27\common\lib\servle
t-api.jar;C:\MyProjects


2. Use javac -cp option : Don't bother with the classpath variable. Just compile your program using the following command line,

javac -classpath ".;C:\apache-tomcat-5.5.27\common\lib\servlet-api.jar;C:\MyProjects" BeerSelect.java
+Pie Number of slices to send: Send


Thanks Sam It worked
Let's get him boys! We'll make him read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1639 times.
Similar Threads
compiling command: servlet-api.jar:classes: . ?
servlet compiling errors
Package doesn't exists - error!!- How to resolve?
Compiling custom imports
attributes and listeners HF p171-176
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:33:01.