Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

package confusion...  RSS feed

 
Lucy Smaile
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problems understanding what the package structure is supposed to be for java beans in Tomcat.
The only way I can get packages to work is to compile with:
javac -d c:/jdk1.3/jre/classes Rotator.java
which puts the class file in the jdk.

My book isn't really very clear, but I think it says that the class file should be inside the proper directory structure in WEB-INF/classes, within the webapp. I can't get this to work - I just get a class not found error.
Is this what I should be trying to do, and if so does anyone know why it wouldn't work?
THanks
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Verify that you have your folder that corresponds to your package name under the classes directory in tomcat.
 
Lucy Smaile
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha! It seems to work if I compile with
javac -d c:/devel/jsp-intro/Web-inf/classes Rotator.java
but not if I compile it somewhere else then put the class file manually into the proper directory. I wonder why this is?
Oh well...
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the answer to this is the simlar to the your other question. IN order to compile a javabean correctly into a package, it must be in its package folder structure, and both the location of the source code file and the root of the package must be in the classpath. So if you file is in
c:\com\chanoch\javabean\MyJavaBean.java
you can compile it with
java -classpath c:\;c:\com\chanoch\javabean\ MyJavaBean.java
or
java -classpath c:\;. MyJavaBean.java
but only if you are in the javabean directory that your file is in. The you upload the file onto your server in the classes as
classes/com/chanoch/javabean/MyJavaBean.class
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!