cancel
Showing results for 
Search instead for 
Did you mean: 

Export JAR from NWDS does not include external JARs imported to project

Former Member
0 Kudos

Hi.

I'm need to develop and run a batch java program. I'm having difficulty getting the application to find the 2 external JARs at runtime.

For compile time, I have physically imported these 2 JARs into the project. To add them to the build path, I selected "Add Jar". I now see the JARs in the project.

I've also update the Manifest file appropriately by adding this line.

Class-Path: com.sap.security.api.jar logging.jar

However, when running the program from the command line, I get class not found errors.

I noticed that the exported application JAR does NOT contain the needed 2 JARs even though they clearly exist under the project.

Am I going about this correctly? Why do external JARs not get included in the application JAR that is created? Can I somehow force them to be included?

Thanks,

Kevin

Accepted Solutions (0)

Answers (2)

Answers (2)

htammen
Active Contributor
0 Kudos

Hi Kevin,

why don´t you just add the two additional JAR files to the classpath at runtime:

java -cp x1.jar;x2.jar -jar yourJar.jar

This is the easiest way to start your Java app.

Have a look at <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html">java - the Java application launcher</a> for details.

Regards Helmut

Former Member
0 Kudos

Hi Helmut,

If I use this technique, must the 2 jar files exist in the same directory as the application JAR?

Thank you,

Kevin

Former Member
0 Kudos

Hi Helmut,

I added the 2 classpaths as you described, but I get a NoClassDefFoundError on whichever class my application attempts to load first. What am I missing? Any ideas?

Thanks,

Kevin

former_member182294
Active Contributor
0 Kudos

Kevin,

You cannot force them to include in the generated file. What you can do is, keep the external JAR files in system class path by using environment variable CLASS_PATH.

Regards

Abhilash

Former Member
0 Kudos

Thank you for the information. I need a bit more detailed help for how to do this in UNIX system.

Just 3 more questions:

1. Do you mean that in the command line script, I need to run an initial command such as this?

export SHLIB_PATH=/usr/local/opt/myjar.jar

2. Does this impact the Manifest file. Do I still need to reference the jars there?

Kevin

former_member182294
Active Contributor
0 Kudos

Kevin,

1. You can write this export command in user .profile, so that it will be available at run time.

2. You need not mention in the Manifiest file; if the jar file is available in class path automatically it refers to the required files.

Regards

Abhilash