• 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

Package confusion

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. My classpath is .;C:\j2sdk1.4.0\bin
2. I write base class named "person" and create "test" directory in "C:\j2sdk1.4.0\bin" and again put "person" class in.
3. Create another class called "manager" which inherits from "person class in "test" package and create "test2" directory in "C:\j2sdk1.4.0\bin" and again put "manager" class in.
What i got while compiled "manager" class is "package test does not exist" error. Would you please help me out?
Thanks in advance
Kasem


 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I find some problem in your script..
1. no main method , you can't execute manager class if it can be complied.
2. If your package is test ,it's mean the script include of the package(the test directory) , so you just can import test.* or another directory and class include of the test if they exist.
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kasem,
I�m not sure why you are receiving that error. That error is usually indicative that you have a classpath problem, but your classpath looks fine. However, you didn�t mention what command you were using to compile with.
Verify your classpath is being properly read by running the command:
C:\> echo %CLASSPATH%
It should return the classpath you specified above. If it does, the command
C:\j2sdk1.4.0\bin>javac test2\manager.java
Should properly compile your class. If the echo command does not return the proper classpath you found your issue.
If you still have problems, try specifying the classpath at compile time by using the following command:
C:\j2sdk1.4.0\bin>javac -classpath .; C:\j2sdk1.4.0\bin test2\manager.java
That should resolve the problem. If it does, you will need to double/triple check your classpath entry in your environment variable to make sure it is correct. (Sometimes the easiest thing is to delete the entry and retype it fresh).
Yusure is correct that neither of your classes are directly executable since neither has a main method. Regardless, they should still compile.
Good Luck...
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Not offering any answers...)
Kasem,
Your example compiles fine for me as well.
Let me suggest not using the j2sdk/bin directory for your source files. This bin folder is supposed to be the location of binary executable files used by the j2sdk. You're not hurting anything, it would just seem to make a bit more sense to keep Java source files in a location like java/projects or java/source. Just a suggestion...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic