aspose file tools*
The moose likes Beginning Java and the fly likes How to get this package? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get this package?" Watch "How to get this package?" New topic
Author

How to get this package?

arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
hi,
I was making two different classes like this:
public class dbconn
{
package db.dbconnect;
//**** and rest of codes here

another is:
public class testData
{
package test.data;
import db.dbconnect.*;
//**** and rest of codes here
now both java files are in same directory. I am also setting the classpath for current director by giving following command:
set classpath=.;%classpath%
if i echo the classpath it shows the current directory too. If I try to compile the first one it gets compile easily but now if i try to compile the second one it gives error that package not found.
but strangely if i give packe like:
import db.dbconnect.dbconn;
it accepts. why?
Isn't first style also Ok?
Pl give your comments.
regards,
arun
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
First of all the package statement needs to be the first executable statement of your code.
After you compile the first class, you need to create directory structure that mimics the package path and move the class there.
If your class B is in C:\myprogram folder and you are importing db.dbconnect, there needs to be a dirtectory db in c:\myprogram. The db directory should contain a dbconenct directory which should contain the class you are trying to import.
Hope this helps
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
Thanks Shivaji for your comments.
But the strange thing is that I am using command javac -d . dbconn.javaThis itself gives that directory structre which ever is needed.(Though I have also confirmed after physically looking at this and it is there) but still the problem remains same.
regards,
Arun
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get this package?