Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package

 
Dennis Liu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created my own aplication(myApp) under webapps,I put all my own classes under /myApp/WEB-INF/classes.It works fine
I want to put my classes in order.So I created two folders /myApp/WEB-INF/classes/myPackageA and /myApp/WEB-INF/classes/myPackageB
How can one class(A.java) under /myApp/WEB-INF/classes/myPackageA use other class (First.java) under /myApp/WEB-INF/classes
or (B.java) /myApp/WEB-INF/classes/myPackageB?
I put "package myPackageA;" in the first line of A.java and
"package myPackageB;" in the first line of B.java.It doesn't work.
How these classes(First.java,A.java, B.java) can use each other?
Thanks Dennis
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use import myPackageB.*; in the A.java
Use import myPackageA.*; in the B.java
to import those packages' classes...
But all classes under the /WEB-INF/classes/ is available to all classes by default implementation of the web container...
One thing don't forget to compile the codes again with the package name specified... Hope it helps....
 
Siripa Siangklom
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget add "public" precede your class keyword such as
public class A {}
 
zhu a ming
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic