• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JAVA packages

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am trying to get JAVA certified and using the K & B as my study guide. Presently, I am trying to learn about packages and I am having the following problem. I used one of the examples from the book.

In one file called permit.java, I have the following.

package test;
public class permit
{
public void callit()
{
System.out.println ("calling package permit");
}
}

The other file called client.java has the following:

package driver;
import test.*;
public class client
{
public static void main(String[] something)
{
permit checking = new permit();
checking.callit();
}
}

Both these files reside in the java\bin directory. When I try to compile the client.java, I get the following error messages.

C:\java\bin\client.java:2: package test does not exist
import test.*;
^
C:\java\bin\client.java:7: cannot resolve symbol
symbol : class permit
location: class driver.client
permit checking = new permit();
^
C:\java\bin\client.java:7: cannot resolve symbol
symbol : class permit
location: class driver.client
permit checking = new permit();

Any help would be appreciated. Thank you.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a word: CLASSPATH. The java compiler can only find other java files which it can access via the CLASSPATH. So to find the package "test" this needs to be in the CLASSPATH. I'm sure the "K & B" (whatever that is) will tell you how to do this - otherwise read about the CLASSPATH at Sun

A word of advice here; if you are running java etc. from the java/bin directory I can assume you have not set your operating system's PATH environment variable up to include Java? Its not a good idea in the long run to be developing stuff in the /bin directory. Far better is to define a directory outside your java/* directory for developing stuff, since it reduces confusion.
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure "K & B" is Kathy and Bert, as in Kathy Sierra and Bert Bates' Java certification book.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic