This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package does not exist�.javaBeans

 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use javabeans. Here is what I am doing. I have a class called �Constants.java� that is in a package call db. The purpose of the class is to hold my sql strings and reset them if it is production or development (the reason being is that development does not match production exactly)
In my first jsp, �index.jsp�, I included this line�


My thinking is that I need to be able to use the getter methods of Constant anywhere in the application.

I get three errors but the first one is
Package db does not exist
db.Constant = null;
^
In my IDE I set it up the structure like this�

Application
|
|-db
| |-Constant.java
|-JRE�s
|-WEB-INF
|-index.jsp
|-blah.jsp, etc

What am I doing wrong and why?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you compile the bean? Did you place the resulting class file in the WEB-INF/classes hierarchy?
[ February 07, 2006: Message edited by: Bear Bibeault ]
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously my reference seems to be lacking some details as they did not include the instructions you just gave. I thought these things were complied by Tomcat on startup.

No, I did not pre-compile and place in a WEB-INF/classes directory. I have since created a �classes� directory and, after deploy the war file, I copied the �Constant.class� file from it�s location at webapps/applName/db to webapps/applName/WEB-INF/classes but I still get the same problem.

Clearly I am doing something wrong. Can you give me a bit more help please?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make it

webapps/applName/WEB-INF/classes/db


This is Java. You need to maintain the package hierarchy.
 
Pat Peg
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah...thanks sheriffAh...thanks sheriff. I didn�t have the package moved over. It seems to work now. I have another question. I am using eclipse and the structure I presented with the post.
1)Should I just move all packages to the WEB-INF folder?
2)Is there a setting I am missing when I make a WAR file?
3)Web.xml? will this prevent me from having to do number 1?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should ask Eclipse setup questions in the IDEs forum, but I would not mix my Java source files in with the web app. Keep them in a separate location and only move the class files to the appropriate location.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic