Cosmin Cosmin
Cosmin Cosmin

Reputation: 1556

How to add libraries to a project from JBoss AS, since you can't use Maven?

I'm trying to test DI from a Main class, I found the following command:

java
-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
-Djava.naming.provider.url=jnp://localhost:1099
-classpath
"%JBOSS_HOME%\client*;
%JBOSS_HOME%\lib*;
%JBOSS_HOME%\common\lib\jboss-ejb3-vfs-spi.jar;"

bla bla bla

How can I add these libraries to the project's classpath in Eclipse.
For JBOSS_HOME\client I can just add as an external jar jboss-appclient.jar since it has in the manifest all other jars in the client folder.
I can't add the jars through Maven since the jars are from the AS, and not from a repository.
I want multiple solutions on how can I add all these jars in the most elegant way. I don't want to add each individual jar as external jar.

ps: think as if you'd have to tell 100 developers to manually add all jars, this is error prone, you wouldn't want that.

ps2: I'm interested in ways of grouping jars together so that the import will be for only one file.

Upvotes: 0

Views: 3646

Answers (2)

Logan
Logan

Reputation: 2364

If you use maven, you can add the dependencies to your project build file. In the scope of the dependency, choose system. Then put in the path to that jar file. You may need to add a maven property to define your jboss_home folder so you can use it in that file box. I have projects I work with where it uses jboss jar files and we reference the jars like this.

You can also add the jboss maven repository to your maven settings file. Then you can actually pull the jars from the jboss repository when you build.

Here's what it looks like when you point to the file using the Maven Pom Editor in Eclipse. enter image description here

How about creating your own manifest file and pointing to the jar files you need like this.

Manifest-Version: 1.0
Main-Class: com.mypackage.MyMainClass
Class-Path: C:\jboss-5.1.0.GA\client\jboss-client.jar

Upvotes: 1

duffymo
duffymo

Reputation: 308763

It's not that error prone.

And 100 developers don't have to do it. Have one developer do it, iron out the wrinkles, and check it into Subversion. Then have all the developers you want check out the project.

Doesn't Eclipse have a way to point to a directory and add all the JARs it finds into CLASSPATH? You can with IntelliJ.

If you can't work without Maven, then it's become too much of a crutch.

If Eclipse can't add app server dependencies easily, switch IDEs and use IntelliJ.

Upvotes: 0

Related Questions