How to reference a jar from another project in Eclipse

Asked

Viewed 877 times

2

I’m doing a project to test iReport reports, and I was wondering if there’s a way not to include the same jars that already exist in a particular project. Eclipse itself offers the option to reference the classes of this other project, the problem that it shows the path as for example c:\eclipse\projeto. And this worries me because I will share the project in SVN, and it will be that if another developer downloading it will not cause error of targeting the jar?

I would then like to know how to do the directing of the jars, and whether this will cause the above mentioned problem.

  • 1

    I suggest a dependency manager to solve your problem, Maven. See here all its advantages, like installing and things like.

  • @Math for now it gets complicated to insert a dependency manager like the Maven.

  • Well, you can then pass along with your project all the dependencies you use and ask the other developer to include in their project. For I do believe it will give the problem you mentioned due to the real way, and not the relative.

  • Or wait for an answer from someone who has a better idea :)

  • @Math your idea is good too, I’m researching something related to classpath variable in Eclipse. Thank you

1 answer

1

iReport (at least in versions I know) cannot use Eclipse variables.

However, you can adopt a standard in your team using environment variables. Each developer should be responsible for creating and configuring their environment correctly.

So he should point this variable, for example, to the root of the project. This will allow a developer to have multiple or even different workspaces branches of a project.

The problem is that to test a particular project it must ensure that that environment variable really points to that project. This can cause confusion in some cases.

Other alternatives are:

  • In linux environments, you can set up a symbolic link to the jars folder and use this path in iReport. For example, create a link on each machine /etc/projeto1 that points to the jars folder. And put the path of that link in iReport.

  • In Windows, you can use the command subst to set up a virtual drive with the jars. For example, use subs P: c:\workspace\projeto1\lib. Then the default will be that the reports of this project always point to the unit P:. Other units can be used for different projects.

  • Dude, just so you know, I have two projects. One is the application itself, and it contains the jars and the other would be the test project I would like to test the reports created outside the system. A kind of TDD of Ireport.

  • 1

    @Macario1983 You are using Junit or some method main? In either case, add the other project in the classpath by the Eclipse should be enough.

  • I use method Main

Browser other questions tagged

You are not signed in. Login or sign up in order to post.