🔒 Locked
[java] Packages
Advertisement
Original Post
I've got some questions dealing with the use of packages in Java. I'm using Eclipse and I have tried to run an application. This program has got some packages declarations. These declarations creates some errors in the source code. I would like to know what is a package and how could I resolve my problem. Cheers !!
A package is merely a way to group related classes. For instance, java.awt.* contains all (or most) of the classes that are AWT-related.
Packages are represented on disk as a tree of directories, with the files located in the leaf directories. So, if you wanted to run a class with the fully-qualified name of net.gamedev.AwesomeJavaGame, the class file would be located in the "gamedev" directory, which itself is located within the "net" directory.
Try looking at the project directory where Eclipse has the files. You'll see how it's arranged.
Packages are represented on disk as a tree of directories, with the files located in the leaf directories. So, if you wanted to run a class with the fully-qualified name of net.gamedev.AwesomeJavaGame, the class file would be located in the "gamedev" directory, which itself is located within the "net" directory.
Try looking at the project directory where Eclipse has the files. You'll see how it's arranged.
Hint: Google any words in the following paragraphs you don't understand... it's an explanation, though not a "layman's explanation", because I suck at these :)
Packages are somewhere between simple directory structures and namespaces, especially since static imports in java 5.
Methods, fields and classes neither declared as private, public or protected are "package protected", meaning they're friend of all other classes in the package; but not to outsiders.
Some may consider this dirty, but it helps rapid prototype development at times.
Well, some times a class can be hidden deep within a jar file (an external Jar). So if you have errors in your import statements or you have a symbol can not be resolved debug message. You might need to adjust your class path with the appropriate jar entries.
I have a fair amount of experience with eclipse so I can walk you through modifying your class path if you'd like.
Lastly, you are not alone when this happens. I've known great developers that spend hours searching for a third party class in hundreds of jar files (on larger projects). Ultimately, they adjust their class path to include the correct jar and the errors go away.
Let us know if you reslove your issue.
Thanks,
I have a fair amount of experience with eclipse so I can walk you through modifying your class path if you'd like.
Lastly, you are not alone when this happens. I've known great developers that spend hours searching for a third party class in hundreds of jar files (on larger projects). Ultimately, they adjust their class path to include the correct jar and the errors go away.
Let us know if you reslove your issue.
Thanks,
Quote:
Original post by Giuoco
Well, some times a class can be hidden deep within a jar file (an external Jar). So if you have errors in your import statements or you have a symbol can not be resolved debug message. You might need to adjust your class path with the appropriate jar entries.
I have a fair amount of experience with eclipse so I can walk you through modifying your class path if you'd like.
Lastly, you are not alone when this happens. I've known great developers that spend hours searching for a third party class in hundreds of jar files (on larger projects). Ultimately, they adjust their class path to include the correct jar and the errors go away.
Let us know if you reslove your issue.
Thanks,
Basically I have downloaded a tutorial dealing with LWJGL programming. The programme has got lots of import and package instructions. I have tried to run the application on eclipse, it doesn't work, because all the import and packages are all in red...
You have to add the LWJGL jars as a library to the project. Project->Properties->Java Build Path->Libraries
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement