Sign in to follow this  
caseyd

[java] External packages

Recommended Posts

I've been messing around with this most of tonight and just can't seem to figure out how to do this properly. I am working on developing a code base to create games from. I have all the classes in a package called MyGameClasses for instance. More specifically they are in stored like this: /com/mysite/*.class so for instance in my source file I reference them like so: import com.mysite.sprite; Now I would like the devlopment of my core package to be separate from whatever game I am working on. The core classes will also have their own svn repository. I have been trying various methods of adding this group of classes into the build path in Eclipse but none of my source files can *see* the classes. I think I am missing something here. For instance, if I wanted to distribute my package for others to use, but not necessarily have the source code, what would the best way to do that be? And how would I add this distributable package to my own project? Thanks, Casey

Share this post


Link to post
Share on other sites
You need to put all your classes in a JAR file. You then distribute the JAR file as your library. You can use Eclipse to create the JAR or Ant or do it manually.

Share this post


Link to post
Share on other sites
Hm. I created a jar with my classes using sun's jar tool. There must be some type of conflict with the package naming and the way I am referencing it in my source files. Do I need to create a manifest file for using the jar this way?


Thanks,
Casey

Share this post


Link to post
Share on other sites
You only need a manifest if you want the jar to be executable. As alibrary you don't need it. You do need to maintain your directory structure for your packages. So you your on class is com.greatbiz.app.MyMainApp, then MyMainApp.class should reside in the directory com/greatbiz/app inside the JAR file.

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