Solved

CLASSPATH and packages

Posted on 1998-06-09
5
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jsp insert to database example 2 65
Need Help! Getting a syntax error and don't understand why 3 41
Java array 10 63
Html split(text) 2 32
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

726 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