troubleshooting Question

How to include jars in a package (.jar) using Maven?

Avatar of Tolgar
Tolgar asked on
19 Comments1 Solution1360 ViewsLast Modified:
I have a simple Java code that connects to server a updates a field in the object and exits.

Here is my code:


import java.util.*;
import java.lang.*;

class myfirstjavaprog

        public static void main(java.lang.String args[])
        	java.lang.String soapEndpointURL="http://SOMEPATH/main/WebService";
			   try {
					GeckWebServiceSoapBindingStub stub = new GeckWebServiceSoapBindingStub(new, new org.apache.axis.client.Service());
					Geck g = stub.lockGeck(java.lang.Integer.parseInt(args[0]),args[1]);
					java.lang.String solution = g.getSolution();
					solution = solution.concat(args[2]);
				  } catch(Exception e) {

To compile this code I use Maven due to some internal reason.

Here are the commands I use to run the program:

mvn clean

mvn package

setenv CLASSPATH `pwd`/target/GeckoPrequal-2.0.jar:/opt/glassfish/lib/javaee.jar:/home/tolgar/.m2/repository/axis/axis/1.4/axis-1.4.jar:/home/tolgar/.m2/repository/org/apache/axis/axis-jaxrpc/1.4/axis-jaxrpc-1.4.jar:/home/tolgar/.m2/repository/org/apache/axis/axis-saaj/1.4/axis-saaj-1.4.jar:/home/tolgar/.m2/repository/axis/axis-wsdl4j/1.5.1/axis-wsdl4j-1.5.1.jar:/home/tolgar/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/tolgar/.m2/repository/commons-discovery/commons-discovery/0.2/commons-discovery-0.2.jar

java 333333 tolgar sometext

Everything works fine and I can update the solution field with "sometext" as the 3rd input argument.

Now my question is:

I want to put this program in a package (.jar) with the jar files that I add to CLASSPATH as I showed above. Then the users will not need to do anything other than just running the following command:

java 333333 tolgar sometext

Can you please give me step by step instructions on how to make it?

Mick Barry
Java Developer
Join our community to see this answer!
Unlock 1 Answer and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros