cancel
Showing results for 
Search instead for 
Did you mean: 

Exclude external JAR from EAR file

Former Member
0 Kudos

Hi there,

I have an EAR file/project that includes a standard Java project. Both projects are in the same workspace.

The standard java project references an external jar file. This external file is not marked under "Order and Export" in the java build path settings, so I shouldn't be exported.

Unfortunally the external jar file will always be included in the EAR file, even if it's excluded in my standard java project. Is there a possibility to prevent this?

(The jar file is sapjco.jar that should never be deployed to the J2EE server).

First I thought about a library project, but I don't think it's possible to include an external jar file there that can be used in my standard java project.

Has anybody an idea how to use the external jar file during development and leaving it out when building an EAR file?

Best regards,

Markus

Accepted Solutions (1)

Accepted Solutions (1)

former_member182294
Active Contributor
0 Kudos

Hi Markus,

If you are specific about the sapjco.jar, instead of including it in the project references you can include it as a Used DC. But for this you need to have JDI environment. You can follow this steps to include it as Used DC:

Expand your project -> DC Meta Data -> DC Definition -> Used DCs

Right click on Used DCs -> choose the development track -> SAP-JEE -> com.sap.mw.jco.

Choose finish. It will be added to your as used DC, and the JAR file also wont be generated.

Even if you want to use Library project also you should create project as DC Project only. But for sapjco you need not create new project as the DC all ready exist.

Regards

Abhilash

Former Member
0 Kudos

Hi Abhilash,

unfortunally we don't have a DI that we could use. So all projects are "standalone" projects.

Is there maybe any other way to exclude the jar?

Regards,

Markus

former_member182294
Active Contributor
0 Kudos

Markus,

I didnt find any other way to exclude the file from .ear, but I can give alternate solution. I dont know if its a correct way to do it or not..

You can try this..

Copy the sapjco.jar to any of the standrad Class Path Variables:

for example:

Copy the jar file to <b>TSSAP_JAVAX_HOME/lib/</b> (You can find it in the Java build path library).

Then add the environment variable to the path. Follow this steps:

In libraries -> Add Variable -> TSSAP_JAVAX_HOME -> Extend -> From the folder structure select the jar file.

This file will be available for compilation, but it wont be there in generated ear file.

Regards

Abhilash

Former Member
0 Kudos

Hello Abhilash,

thanks, that works fine.

I addition I think it is correct way. You just have to take care that you re-copy the libraries when you install a newer version of NWDS. But I'll try around a little bit if those jars might also be excluded by defining an own variable.

Thanks for your help,

Markus

former_member182294
Active Contributor
0 Kudos

Markus,

Eclipse ignores the standard variables only. If you define new variables again, then again libraries will be copied to the generated archive. That's the reason I have chosen standard SAP variable. What we can do is, we need to find out where this standard variables are configured, so that we can define custom variable also as standard project variable. I will try in that way and update you.

Regards

Abhilash

Former Member
0 Kudos

Hi Abhilash,

hi Markus


I could confirm that defining your own variable works.

I created an user library "SAP_PI_RUNTIME_LIBS" in NWDS preferences Java -> Build Path -> User Libraries and added all PI runtime libs which are already available on the server and therefore not have to be included in the ear file.

In the EJB project I am referencing / using these libs by adjusting Build Path, Tab Libraries -> Add Library "User Library" and select the beforehand defined user library "SAP_PI_RUNTIME_LIBS".


As a result during build of ear these jars are excluded.


Best regards

Jochen

Answers (0)