wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Error when using package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error when using package" Watch "Error when using package" New topic
Author

Error when using package

Matthew Paul
Greenhorn

Joined: Aug 04, 2011
Posts: 3
Hi everybody, I'm new to the forums, so thanks for letting me join in on the fun! I've been programming java for about 4 months now.

My problem seems to be the way I'm trying to tell my java to run a class in a package. Whenever I try to run my VehicleTest.class file from my terminal I get the following error:



As you can probably tell, I'm using Ubuntu Linux (Natty). I'm almost certain that my java is set up correctly, due to when I use the command "java -version" it pops up with"
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)"

I can run programs that are not in a package, or in the default package with no problem. I know that my code is correct because I use Eclipse IDE and it gives no errors and runs perfectly in the internal console.

I don't really know how to show the hierarchy of my files, but here goes.

Workspace
Starting out with Java
bin | src
practice | practice
VehicleTest.class | VehicleTest.java

The class is part of the package practice. I've been searching for an answer for about an hour and a half ( ) with no luck. I'm pretty sure it's a simple answer and that's why it's so frustrating to me. If you want it, here's the code dump from my files. Thanks so much (in advance) for helpin' me out!

Vehicle.java


VehicleTest.java

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

You need to specify the full class name, while the parent of the package's root folder is on the class path. In this case, go back to the bin folder and run the code as java practice.VehicleTest.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Matthew Paul
Greenhorn

Joined: Aug 04, 2011
Posts: 3
Oh wow... yeah, that was a super easy thing to do... Thank you very much for answering so promptly Rob! I will remember that as I continue learning more about using packages and such.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

You're welcome.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to JavaRanch Matthew
Matthew Paul
Greenhorn

Joined: Aug 04, 2011
Posts: 3
Thanks for the welcome Mr. Venkatasamy!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error when using package