Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat - Path for user-defined package?

 
Viji Bharat
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All:
I have installed Tomcat and I have some difficulties in creating my own package. My problem is this:
I have created a sample program HelloWorld.java and have placed HelloWorld.class under $TOMCAT_HOME/webapps/<<my dir name>>/web-inf/classes directory. I can invoke the servlet using my web browser. No problem.
I want to create a new class and place it in a package say 'myutil' and I want to import this new class in HelloWorld.java and use it. My directory structure for this new package is .../webapps/<<dir name>>/web-inf/classes/myutil.
When I try to recompile HelloWorld.java with import myutil.* statement added to it, it gives me an error 'package myutil doesn't exist'
My doubts:
1. Is my package directory correct?
2. I have included myutil in the Environment classpath. Should I change any other Tomcat configuration files to include this classpath?

Any help is appreciated.
Viji

[This message has been edited by Viji Bharat (edited January 17, 2001).]
 
Cynthia Yao
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you need to create a class package to be used, then the dir should be under /web-inf/classes/<package name>/XX.java.
If you need to map visual directory. then you should do /webapps/<folder name>. Then the strctur under that folder should be exactly like the ROOT. And you should update in <tomcat>/conf/server.xml
<Context path="<folder>" docBase="webapps/<folder>" debug="0" reloadable="true" >
</Context>
 
Viji Bharat
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cynthia:
Thanks for the response. This is my package directory set up but still I get an error 'myutil.*' does not exist when I try to compile HelloWorld.java. Any reason why this should happen?
......
webapps
|
|_Mydir (my directory)
|
|_web-inf
|
|_classes (has HelloWorld.java & HelloWorld.class)
|
|_myutil(My package directory that has html.java & html.class files)
conf/server.xml is set up to use Mydir context. I don't have any problems in accessing simple servlets with their respective class files under webapps/Mydir/<<simple servlets>>
Any more help?
Thanks,
Viji
PS - How do I represent a directory structure in these posts? I am unable to use any HTML code! It simply displays the tags as text!!

[This message has been edited by Viji Bharat (edited January 17, 2001).]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason you get that error is probably because the compiler can not see the classes that are in WEB-INF\classes etc.
You need to either put WEB-INF\classes on your classpath or use the form of the javac option that creates a temporary classpath.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic