NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Taaadow
Joined: 20 Jan 2010 Posts: 1
|
Posted: Wed Jan 20, 2010 4:14 pm Post subject: Sharing common code between Java Projects? |
|
|
I have 2 web applications that are very similar and share a lot of the same code. I have googled all day and can't find a straightforward answer to this question: How can I share code between the two projects in NetBeans? I've tried adding the the folder that contains the source packages to both projects but NetBeans complains that only one project at a time can use this source folder. I've been reading up about Enterprise projects (.ear) but still can't find a straightforward answer on how to accomplish this.
Does anyone know a reasonable way to share code in NetBeans so that I can have a folder that contains code that will apply to both projects and when I deploy either project it will include the code from the shared source files, or do I just have to keep copying the code from one project to another? |
|
| Back to top |
|
 |
whiteknave
Joined: 05 Feb 2010 Posts: 1
|
Posted: Fri Feb 05, 2010 7:30 pm Post subject: Re: Sharing code |
|
|
The easiest solution would be to put the shared code into a library or .jar file and the .jar file to your project library.
If you use this method, you'll probably want to put the shared code in a 3rd project. That way, you only have to maintain it in one spot. If you have to make changes, you just recompile/recreate the .jar file, and copy it to each project's /lib directory. |
|
| Back to top |
|
 |
hartman
Joined: 26 Sep 2008 Posts: 17
|
Posted: Tue Jun 08, 2010 5:31 pm Post subject: Sharing code between multiple RCPs |
|
|
You hit the nail on the head in regard to "straightforward".
Here is Geertjan's recommended approach:
http://blogs.sun.com/geertjan/entry/sharing_code_between_different_netbeans
The wiki describes the difference between a suite and a cluster, but it's not clear what the differences are between "Add Project..." and "Add Cluster..." in the Project Properties dialog window, and why you would choose one over the other. Furthermore, it's not clear why a stand-alone module cannot depend on another stand-alone module. From my limited understanding, this would be the most straightforward approach. |
|
| Back to top |
|
 |
Geertjan Wielenga Posted via mailing list.
|
Posted: Tue Jun 08, 2010 8:36 pm Post subject: Re: Sharing common code between Java Projects? |
|
|
hartman wrote:
| Quote: | You hit the nail on the head in regard to "straightforward".
Here is Geertjan's recommended approach:
http://blogs.sun.com/geertjan/entry/sharing_code_between_different_netbeans
The wiki describes the difference between a suite and a cluster, but it's not clear what the differences are between "Add Project..." and "Add Cluster..." in the Project Properties dialog window, and why you would choose one over the other. Furthermore, it's not clear why a stand-alone module cannot depend on another stand-alone module. From my limited understanding, this would be the most straightforward approach.
| "Add Project" lets you add a single project, "Add Cluster" lets you add
a folder containing multiple projects. A stand-alone module cannot
depend on another stand-alone module because they're not on each other's
classpath. That's what the application-types are for (NetBeans Platform
Application and NetBeans Module Suite).
To continue these discussions, join the correct mailing list:
address-removed
Gj |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|