For Programmers: Free Programming Magazines  


Home > Archive > Java Help > April 2005 > Tomcat: can't import package....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tomcat: can't import package....
Frances Del Rio

2005-04-27, 4:01 pm

Frances Del Rio wrote:
> Juha, just as an experiment I packaged a simple helper class I have in
> an app.. class is sH.class (simple class that I use just to store vars
> to generate HTML code..) I put this class in WEB-INF\lib\com, then
> converted this 'com' into a jar.. ('jar cf sH.jar com' in WEB-INF\lib)
> so now I have WEB-INF\lib\sH.jar (sH.jar = com\sH.class..) and if in
> WEB-INF\lib I do 'jar tf sH.jar' I get
>
> META-INF/
> META-INF/MANIFEST.MF
> com/
> com/sH.class
>
> so far so good, right?
>
> so in servlet (which is in WEB-INF\classes\hm) I now do
>
> import com.sH; but when compiling servlet get told that
> 'package com.sH' does not exist..
>
> I must be missing something here..
> (again, Tomcat knows to look for packages in WEB-INF\lib, right? Juha,
> thanks again.. Frances


ok, I think mistake I made is I gave package same name as class inside
'com' dir.. what I did now: in WEB-INF\lib I have com\sH.class, so:

to create jar file: "jar cf html.jar com", which, when I do
"jar tf html.jar" returns:

META-INF/
META-INF/MANIFEST.MF
com/
com/sH.class

in servlet (in WEB-INF\classes\hm) I do

import com.sH;

yet when I compile I get told 'package com doesn't exist'..

now I REALLY don't know what I am doing wrong.. would appreciate
leads... thank you... Frances


Rivky

2005-04-27, 4:01 pm

are u trying to compile the servlet or run/access thru browser the
servlet?

If you are just trying to compile -
I think maybe the issue is not in the package structure. it's in the
compiling tool you're using. How are you compiling your code? Make sure
that the jar is in your classpath or if you're using one of the
standard IDE's. that you have it listed, with the correct path, as one
of the required libraries.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com