• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Unable to compile Packge servlet

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Marshal
Posts: 67497
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Java in General where compiling issues are best dealt with.
 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
AsifAimen Iqbal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks Sam It worked
 
reply
    Bookmark Topic Watch Topic
  • New Topic