This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Setting up packages (very confused) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting up packages (very confused)" Watch "Setting up packages (very confused)" New topic
Author

Setting up packages (very confused)

John Jaspers
Greenhorn

Joined: Mar 27, 2003
Posts: 9
I realize this is kind of a silly question, but what they heck: If I have a package whos directory structure is say C:\packages\com\whatever and I want to add to the whatever package, how would I do this and have the program find the package? Do I have to add this directory structure to my classpath, because using import statements doesn't seem to do it in JBuilder 8, and I can't figure out what I'm doing wrong.
And after getting it set up correctly, what do I use as the import line? import packages.com.whatever.*, or just com.whatever.*? How would I set it up so that it were only com.whatever.*?
Thanks in advance.
Susilo Saja
Ranch Hand

Joined: May 27, 2003
Posts: 91
Hi John,
Let's say you have a java file C:\package\com\whatever\Test.java, if you put C:\package in your classpath, then the package for Test.java is package com.whatever; And if you want to import Test.java, it will be import com.whatever.Test;
If you already define a package for a class, yes you have to put it in the classpath so that javac and java can find it. But it could be different for IDE. It may look for the CLASSPATH environment variable, or you might have to set the library by your own in that IDE. I don't know about JBuilder. Hope this help.
Susilo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting up packages (very confused)