Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dealing with importing conflicting package names in java.

Started by ManaStone Feb 22, 2012 at 12:29 AM 4 replies 6.9k views
Original Post
ManaStone
ManaStone
I'm downloaded the jgoodies jar file, but I can't import it right now because the first package inside it is named "com" and there is already a "com" package in one of the default global libraries. Is there anyway I can get around the naming ambiguatiy so I can import the jgoodies package? Is there a tool I can use to rename the package inside the jar file from "com" to "com2"?
-----------------------------Download my real time 3D RPG.
Neophyte
Neophyte
What makes you think that there being a package named "com" in two different libraries is causing you trouble? I ask because it is certainly not causing you trouble, so if you are having problems it comes from somewhere else, and you have not given information to let us help you solve it.
ManaStone
ManaStone
I think that is the thing that is causing me trouble because I tried creating a test package called javax and it gave me the same problem when trying to import it from a jar file. I renamed it to javax2 and it resolved the issue. It appears to be a naming conflict.
-----------------------------Download my real time 3D RPG.
arbitus
arbitus
This cannot be your problem, as com is the single most common package prefix in existance, next to possibly org. Almost every java library package is prefixed with com.

This is because a major Java convention is to begin all of your package names with your domain name, which typically takes the form of [CompanyName].com. Since package naming is intended to go from least specific to most specific, the .com is prepended, so you end up with com.[CompanyName].[Module].[Module/Class]

Are you importing using star(*)? Something like import com.*? If so, try just importing the class names that you are using in the file, and see if you are still having problems.
ManaStone
ManaStone
Actually, I retried that javax thing and I am not getting the error I got before. So I guess you are right, that isn't the problem.
-----------------------------Download my real time 3D RPG.
ManaStone
ManaStone
Ok, nevermind this. I found the problem. I took a closer look at the contents with the jar tool and it appears that I downloaded the documentation files instead of the class files. I apologize if I wasted anyone's time.
-----------------------------Download my real time 3D RPG.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.