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
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
posted
0
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".
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!!!
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,