Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Manage Single Java Class used in Different Projects(Is it possible to have a single class compile in different projects?)
Manage Single Java Class used in Different Projects [message #1791931] Sat, 07 July 2018 23:05 Go to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 9
Registered: December 2017
Junior Member
I have 2 companion projects that share one particular class. Is there a way to get eclipse to access that class in both projects so only one needs to be maintained? I guess I am asking for that class to be managed in one project but that copy be automatically included when the other is compiled. TIA.
Re: Manage Single Java Class used in Different Projects [message #1791936 is a reply to message #1791931] Sun, 08 July 2018 09:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6041
Registered: July 2009
Senior Member
Hi

You could arrange for one project's build to automatically copy from to the other, but since that's pretty stupid, the support is not great.

Much better to create a common/library/shared/util project in which the common functionality is maintained. e.g. org.eclipse.equinox.common, org.eclipse.emf.common, ...

Regards

Ed Willink
Re: Manage Single Java Class used in Different Projects [message #1791938 is a reply to message #1791936] Sun, 08 July 2018 14:42 Go to previous messageGo to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 9
Registered: December 2017
Junior Member
I've never created my own library. I'll have to research that. Is the technique to create a 3rd project with that single class, then build that as a library and finally include that library in the build path of each project? That seems like the long way around the barn but if that is the best programming practice then I'll try it. Thanks.

[Updated on: Sun, 08 July 2018 14:43]

Report message to a moderator

Re: Manage Single Java Class used in Different Projects [message #1791940 is a reply to message #1791938] Sun, 08 July 2018 15:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6041
Registered: July 2009
Senior Member
Hi

If you use MANIFEST.MF, you just build a third plugin and specify a dependency. It won't be long before you have more common material to put in it.

If you don't use MANIFEST.MF, you should learn, since everything you do must be a "long way around the barn".

Regards

Ed Willink
Re: Manage Single Java Class used in Different Projects [message #1791944 is a reply to message #1791940] Sun, 08 July 2018 17:30 Go to previous messageGo to next message
Dennis Putnam is currently offline Dennis PutnamFriend
Messages: 9
Registered: December 2017
Junior Member
Thanks. I'll look into that too.
Re: Manage Single Java Class used in Different Projects [message #1791957 is a reply to message #1791944] Mon, 09 July 2018 04:08 Go to previous message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 76
Registered: February 2010
Location: Bangalore, India
Member
Folders or files can be linked using New File/Folder - > advanced option.
https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-45.htm


Sarika Sinha
JDT Programmer
Previous Topic:Terminating process being debugged takes much longer in Photon
Next Topic:Problem with javadoc when using modules
Goto Forum:
  


Current Time: Sun Sep 23 19:36:24 GMT 2018

Powered by FUDForum. Page generated in 0.01705 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top