Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CLASSPATH and packages

Posted on 1998-06-09
5
Medium Priority
?
241 Views
Last Modified: 2013-11-23
Im about going out of my skull here..
First off im using the JDK1.1.5 on a WIN95 system (single user)
I have been working with Java for a while now however I have never created my own packages or really even had to set the CLASSPATH.  I've only imported the API packages up til now.
Now I've wanted to experiement with creating my own packages and using packages that I have received from other people (I found one that was written by Jim Buzbee called houseblend that allows you to rotate and manupulate fonts, etc...its at www.nyx.net/~jbuzbee/font.html (for a plug))
anyway using this as an example of my problem...
the package is called houseblend
I have set up my CLASSPATH as the following:
set CLASSPATH=c:\jdk115\;c:\jdk115\myjava\classes
and have tried putting the package houseblend in a directory off both of these directories the class file that is my concern is called HersheyFont.class
so the path to that file is c:\jdk115\houseblend\HersheyFont.class
The HersheyFont.java file compiles without a hitch
but when I try to compile the test.java class that came with the package it gives me the following error which leads me to believe that I have somehow specified the CLASSPATH or the directory structure wrong:
test.java:19: Package houseblend not found in import
OR
if i have the period "." at the front of my classpath the compiler would give me this error:
error: File.\HersheyFont.class does not contain type HersheyFont as expected but type houseblend.HersheyFont.
Please remove the file or make sure that it appears in the correct subdirectory of the class path

Obviously something is messed up with my classpath or subdirectories (very few errors are THAT specific but I still cant seem to figure it out)
The test.java has multiple import statements one of which is:  import houseblend.*;
and there is a package statement in the HersheyFont class

Any comments or questions would be greatly appreciated
I'll assign it as easy for now (it sure SEEMS easy... the documentation I have read about creating packages is straightforward)
I think Im in the forest so deep that i cant see the trees

Mark


0
Comment
Question by:mbunkows
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1222773
Where is test.java class located and what package does it belong to?
0
 

Author Comment

by:mbunkows
ID: 1222774
test.java is located in the same directory as the package itself
so in the example situation it is located in the c:\jdk115\myjava\classes\houseblend directory.. it is not part of any package itself... it was just included to test the actual
font package (and it imports the package)

If I remove the package statement from the source code (and the import) and run the test class it works (because its in the same directory)

but id really like to know what im missing here

0
 
LVL 5

Accepted Solution

by:
msmolyak earned 200 total points
ID: 1222775
Classes which belong to different packages should not really live in the same directory. If the class belongs to a package, then its directory is pretty much defined (relative to CLASSPATH directory). I am not exactly sure where you should put the class not belonging to any package which imports other packages.  Try either putting test.java into some package (houseblend or your own) or try moving it out of houseblend directory (e.g. one level up).
0
 

Author Comment

by:mbunkows
ID: 1222776
your quick ... let me try this out
be back in 5-10 minutes :)


0
 

Author Comment

by:mbunkows
ID: 1222777
Amazing!
I guess it makes since from a organizational point of view
the funny thing is if i would have tried it the way i was actually going to use it, it would have worked.

Thanks alot for the help (and helping me out of the forest)
Mark
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question