• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package problem

 
Jon Krogell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I'm trying to import my own package I get this error:
"error: File /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/Car.class does not contain type Car as expected, but type stuff.jkrogell.Car. Please remove the file, or make sure it appears in the correct subdirectory of the class path."
Also, if I make a main method to the Car class, JBindery will give me this dialog box:
"Unable to launch java application.
The main class "Car" could not be loaded. Either it is not in the classpath or has a static initializer that uses a class not in the classpath."
I can't understand how it couldn't be in the Classpath.
So, what should I do to get this it to work.
Yeah, and if you didn't notice, I'm on Mac (OS 9.1) and I've got MRJ 2.24 and SDK 2.2 installed.
Thanks in advance.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this in your classpath?
/GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/
It sounds like you have this directory structure instead.
/GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/stuff/jkrogell
 
Jon Krogell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this in your classpath?
/GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/

Yes. All the Java Runtime Classes are in there so I don't know how it couldn't be in the classpath. I've also manually added that folder to the classpath.
It sounds like you have this directory structure instead.
/GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/stuff/jkrogell

Nope, both the Car.class and Car.java files are in /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/.
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your import statement look like?
 
Jon Krogell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My import statment looks like this:
import stuff.jkrogell.*;
In the Car class I have this package statment:
package stuff.jkrogell;

[This message has been edited by Jon Krogell (edited April 15, 2001).]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jon,
What directory are you in when you execute this? Do you have . in your classpath? If you are in the /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/ and . appears in your classpath before /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses It could cause the problem you are seeing. If you execute this from the /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses or any directory other than /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/ it should run.

------------------
Hope This Helps
Carl Trusiak, SCJP2
 
Jon Krogell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no period ( . ) in the classpath. If you are referring to
Nope, both the Car.class and Car.java files are in /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/.
that period is the sentence ending period.
I'm compiling a Test.java file located in /GXP30/Desktop Folder/, it looks like this

Now the interesting thing is that the "import stuff.jkrogell.*;" isn't required, the I will get the error even if I haven't got it. If I change the import statement to "import stuff.jkrogell.Car;" it'll work, but none of the other classes in that package will. That won't work if the classpath doesn't include /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/stuff/jkrogell/ (I thought /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/ would do the trick, downloaded Jar files placed in that folder work with that in the classpath). Anyway, having "import stuff.jkrogell.*;" still doesn't work.
 
Jon Krogell
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, it works now, the solution was that I had to JAR the the 'stuff' folder and place the JAR file in /GXP30/System Folder/Extensions/MRJ Libraries/MRJClasses/. I'm still wondering why it doesn't work without the JAR thing, it's a bit ineffective to JAR the whole thing (well, ok, it's not much but anyway) for every little change to the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic