0

I have used add as link option available in Visual Studio 2010 (Screen shot attached below).

https://dl.dropbox.com/u/70687768/link.png

Same thing I want to achieve in Java using NetBeans IDE.

When try to attach file it gives below ErrorAddAsLink.JPG.

https://dl.dropbox.com/u/70687768/ErrorAddAsLink.JPG

In brief I want to have a common code (Ex methods : readFileAsString(path) , LoadXML(path) ) which will be kept at a location and should be able to accessed by multiple projects (Not as jar because I want to give access to everybody to see and alter those methods too)

I referred below link , but not helpfull,

“Add as link” in Netbeans?

3
  • Sounds like bad practice to me. Is there a particular reason why you don't simply create a Netbeans class library project and share that instead of a jar built by it? Doing that combined with version control (SVN, etc.) is what you should be doing... Commented Oct 19, 2012 at 12:43
  • Thanks for taking time to help predi, I tried by way you guided. Then also it is pointing to jar built by it in dist folder. If you pass any sample link how to achieve it, that would be great. Even though it is a bad practice I have some worth profits in it like , irrespective of author any Team member can change these methods in common functions and all the others should get those updates when they do svn update. unlike in jar for every new update they need to compile and attach new jar. 1.Tedious to follow whether he has taken new jar or not and all projects Commented Oct 22, 2012 at 10:44
  • Yes, that's right. It is pointing to a local JAR when you do it my way but the JAR is built based on code you share with your team. And this JAR is built every time when you clean/build your main project which depends on it (it doesn't have to be re-attached to the main project if you do it right). All you and your team should make sure of is that the code in local working copies is updated. Netbeans natively supports SVN so you and your team can see when your local copy is outdated via icons in Projects explorer. Commented Oct 22, 2012 at 11:49

1 Answer 1

1

Just in case, I'm posting the steps on how you do what I describe in comments to the question (I'd consider this a viable alternative).

  1. create a Netbeans Java class library project for the code that you want shared
  2. commit this code to your SVN or a similar system (you can commit an entire project if you see that as beneficial)
  3. have your team check-out the code/project into a local working copy
  4. open this as a project in NB so it is beside the opened main project(s)
  5. add this project as a library to your main project(s); right-click Projects > [main-project-name] > Libraries and select "Add Project..."
  6. select the new java class library project and confirm

Now your main project depends on another project's JAR, so this JAR will be rebuilt whenever it's code is updated and before main is built. You don't have to build it individually.

Each team member may now edit the common code and commit it to SVN (can be done through Netbeans IDE without any external clients such as Tortoise). Others just need to check for updates often enough and update when necessary.

This has the same effect as having an external file as a link but it's much more organized. I don't think Netbeans has the exact feature you described.

I'm assuming Netbeans is being used for Java coding in this case.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your Help predi.. I did it like that and its working fine for me. But I am not able to integrate SVN with netbeans, when I am trying to fetch history , it is showing following error. org.apache.subversion.javahl.ClientException: E175002: OPTIONS of '/svn/devbuild/trunk/Solutions/Seismic/Source/Binaries/Seismic/src/java/seismic_web_service/seismic_merge.java': 500 Internal Server Error (svn.pointcrossblr.com) E175002: OPTIONS request failed on '/svn/devbuild/trunk/Solutions/Seismic/Source/Binaries/Seismic/src/java/seismic_web_service/seismic_merge.java'
@vajrakumar hmm.. thats's strange. Have you tried using a different client? You can set that up in Tools > Options > Miscellaneous > Versioning > Subversion. Note that javahl is intended for SVN1.7 and will fail if you did check-out with an older version. See here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.