• Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing packages mean what?  RSS feed

 
Hugh Sasse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously an error like:

javac alice/authoringtool/dialog/AliceAlertContentPane.java
alice/authoringtool/dialog/AliceAlertContentPane.java:38: package edu.cmu.cs.stage3.swing does not exist
public abstract class AliceAlertContentPane extends edu.cmu.cs.stage3.swing.ContentPane {

means that the swing package is missing. But my reading of the FAQs
and the Sun tutorial is that a package is just a directory whose files
have
package Swing
(or whatever package is in question) at the beginning. There isn't actually a file that javac should be looking for. The directory itself exists. So what does this error mean? What is actually missing for this error to get raised? Maybe a better question is: where do I look to find out how to interpret error messages in the java environment? I'll understand most of them, having used C, C++, Perl, Python, Ruby etc,
but with Java specific terminology...

I'm about half-way through "Head First Java", so I may find this later,
but you know how it is: people managing projects (to extend things) want
to see results, so I'm trying to get "cutting metal", so to speak. Ideally
I'd wait till I knew this inside out.

Thank you.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Swing package is javax.swing.
The package that is missing here is edu.cmu.cs.stage3.swing.
This is nothing to do with the standard java swing classes.

What you need to find is a jar file containing this missing package.
Package names are often based on the domain name of the organisation that produces them, so if a web site called edu.cmu.cs exists, this might be a good place to start. Alternatively, you could google the package name.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just re-read your post. You say
The directory itself exists.
Do you mean that you have a directory called edu/cmu/cs/stage3/swing that contains class files ? If so, then you just need to include the parent directory of the edu directory in your classpath.
 
Hugh Sasse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[I thought I'd set this to email mw when people replied. Sorry for the delay in responding.]

Thank you for your prompt replies. I think part of the problem is that the Alice system I'm trying to extend was originally developed in Java 1.3. It seems I need some tools to help me convert old code. But I can't be certain that that is the problem [and don't know where I'd find a 1.3 javac to test this :-) and if I did would it work on Solaris9...]

I do have the parent directory to the edu directory on my CLASSPATH, and
that made a number of errors disappear before I posted, but I'm still getting these. The files do seem to exist: the classes as part of this package do have the corresponding files in the swing directory, but then the error isn't about missing classes, it is about a missing package. The semantics of this are somewhat obscure to me at the moment. Perl5 had packages that were not files as such, 'bless'ing things into packages as part of making them classes, but Java doesn't need packages in order to have classes, so that's not the same. So I'm still of the belief that I don't know what constitutes a package exactly. Knowing that may help.

[This feels like "Until you know the answer, you don't know the right questions to ask to get it" :-)]

Thank you
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to compile Java 1.3 source code on newer versions (1.4, 5.0) without any modifications, so you don't need a tool to convert the old code.

If you are still getting "package not found" errors, then your classpath is still not correct, or you don't have all the classes that are necessary in the edu/cmu/... directory.

Packages are just a way of organizing Java classes. Have a look at The Java Tutorial: Creating and Using Packages

You can have packages in a directory structure on your disk, in which case you have to add the parent directory to the classpath, or you can have them in a JAR file (in which case you put the JAR file in the classpath).
 
Hugh Sasse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like my CLASSPATH got unset at some point. OK, I'm getting
different errors now. They are references to missing org.python.core
which I think relates to jython, so I grabbed that. The jython jar file has lib/java/org/python/core, so my next question is: If I have the directory
of a jarfile on the CLASSPATH, say /scratch/exampledir, then can
I have /scratch/exampledir/lib/java on the path and have the org.python.core
inside the jar file resolved correctly?

If not, then I'll just unpack the jar and amend the paths accordingly.
I think it would be neater if I didn't have to unpack it.

Thank you.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your classes are in a jar file then you need to include the jar file (including its path) in the classpath
i.e. you need
/scratch/exampledir/jython.jar
in your classpath.
If just the directory is in your classpath, the jar files in that directory will not be searched.
 
Hugh Sasse
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thank you. I'd forgotten that detail.
I've unpacked it for now and am beginning to make some progress.
Thank you for getting me unstuck. I can probably give you
some peace for a bit now :-)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!