Sign in to follow this  
ManaStone

Dealing with importing conflicting package names in java.

Recommended Posts

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"?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this