Jump to content

  • Log In with Google      Sign In   
  • Create Account

Dealing with importing conflicting package names in java.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 ManaStone   Members   -  Reputation: 148

Like
0Likes
Like

Posted 21 February 2012 - 06:29 PM

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.

Sponsor:

#2 Neophyte   Members   -  Reputation: 544

Like
1Likes
Like

Posted 22 February 2012 - 05:21 AM

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.

#3 ManaStone   Members   -  Reputation: 148

Like
0Likes
Like

Posted 22 February 2012 - 09:43 AM

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.

#4 arbitus   Members   -  Reputation: 436

Like
0Likes
Like

Posted 22 February 2012 - 10:05 AM

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.

#5 ManaStone   Members   -  Reputation: 148

Like
0Likes
Like

Posted 22 February 2012 - 10:25 AM

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.

#6 ManaStone   Members   -  Reputation: 148

Like
0Likes
Like

Posted 22 February 2012 - 10:46 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS