Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to compile Packge servlet

 
AsifAimen Iqbal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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>

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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
  • 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!!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java in General where compiling issues are best dealt with.
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator


Thanks Sam It worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic