troubleshooting Question

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

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

Here is my code:

package com.mywork.tools.GeckoPrequal;

import com.mywork.tools.GeckoPrequal.ws.*;
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 java.net.URL(soapEndpointURL), new org.apache.axis.client.Service());
					
					Geck g = stub.lockGeck(java.lang.Integer.parseInt(args[0]),args[1]);
					
					System.out.println(g.getSolution());
					java.lang.String solution = g.getSolution();
					solution = solution.concat(args[2]);
					
					System.out.println(solution);
					g.setSolution(solution);
					
					stub.saveGeck(g,args[1]);
					
				  } catch(Exception e) {
					System.out.println(e.getMessage());
				  }	
        }
}

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 com.SOMEDOMAIN.tools.GeckoPrequal.myfirstjavaprog 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 com.SOMEDOMAIN.tools.GeckoPrequal.myfirstjavaprog 333333 tolgar sometext


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

Thanks,
ASKER CERTIFIED SOLUTION
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