The moose likes Servlets and the fly likes package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "package" Watch "package" New topic


Dennis Liu

Joined: Dec 03, 2003
Posts: 9
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

Joined: Jun 08, 2002
Posts: 3178
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....

Co-author of SCMAD Exam Guide, Author of JMADPlus
Siripa Siangklom
Ranch Hand

Joined: Jan 26, 2004
Posts: 79
Don't forget add "public" precede your class keyword such as
public class A {}
zhu a ming

Joined: Oct 05, 2003
Posts: 9

=======================<br />s=(LinkNode *)malloc(sizeof(ListNode));<br /> s->date=ch;<br /> s->next=head;<br /> head=s;<br /> ch=getchar();
I agree. Here's the link: http://aspose.com/file-tools
subject: package
Similar Threads
Can applet use the jar file in the WEB-INF/lib
How to compile two classes that need each other
Help! Difficult in compiling Servlets
Doubt in WEB-INF/lib