aspose file tools*
The moose likes Beginning Java and the fly likes Unable to compile Packge servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Unable to compile Packge servlet" Watch "Unable to compile Packge servlet" New topic
Author

Unable to compile Packge servlet

AsifAimen Iqbal
Greenhorn

Joined: Mar 06, 2009
Posts: 9
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
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


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
AsifAimen Iqbal
Greenhorn

Joined: Mar 06, 2009
Posts: 9
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>

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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".
AsifAimen Iqbal
Greenhorn

Joined: Mar 06, 2009
Posts: 9
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!!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Moving to Java in General where compiling issues are best dealt with.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 605

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


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
AsifAimen Iqbal
Greenhorn

Joined: Mar 06, 2009
Posts: 9


Thanks Sam It worked
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to compile Packge servlet