File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Please heeelp..Can't get Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please heeelp..Can Watch "Please heeelp..Can New topic

Please heeelp..Can't get "packages" to work

Con Lu
Ranch Hand

Joined: Aug 27, 2002
Posts: 38
I have a really frustrating problem, which I have been unable to solve for some time now. I have followed the instructions in a number of books but it still doesn't work. Can anybody help me?
The problem:-
I want to create a package on my computer, but when I try to import the package in a class on another directory, the package cannot be found by the compiler.
For example the package I want to set up is and inside that package I want a class named
The Steps I have done are as follows:-
1) On my WIN98 laptop, create the directories c:\com\p1\lu
2) Inside the directory lu created a class with the following code:-
public class Class1{
public void setName(String name){
Code compiles fine
3) Change my class path on my autoexec by the following:-
set CLASSPATH = .;c:\com\p1\lu
4) Rebooted my computer
5) At DOS prompt checked that the class path is correct by entering set
6) In another directory on my computer create a class named with following code:-
public class TryPackage{
public static void main(String []args){
Class1 obj = new Class1();
Does NOT compile with following error message:- ackage does not exist
Any help would be much appreciated. I have been tearing my hair out over this for quite some time now.
P.S.I also ran into another problem which might be related - I tried to run the "Hello World" example in JBuilder7 and a similar compiler error resulted with the package name.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Your problem here seems to be a simple "typo".
public class Class1{
surely that should be ?

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
Your classpath setting needs to be c:\ instead of c:\com\p1\lu.
For instance, on my system I have a Packages directory that I put all my packages in, so the structure is like so...

My classpath statement include c:\packages, the directory ABOVE my actual package directory. Now I can actually find all these packages by importing com.domainX.packageName
[ August 27, 2002: Message edited by: Joel Cochran ]

Wait a minute, I'm trying to think of something clever to say...<p>Joel
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Please heeelp..Can't get "packages" to work
jQuery in Action, 3rd edition