-2

I have a situation of running a jar file. I have added the jar file in maven repo and added the dependency in my pom. I am trying to run following command in java file using process executer.

pom dependency:

       <dependency>
            <groupId>com.vmware.vcac.qe.tools</groupId>
            <artifactId>vcac-tools</artifactId>
            <version>1.0.0</version>
        </dependency>

Code in java:

String command = "java -cp " + jarPath + " " + className + " " + propertiesFilePath;
Runtime.getRuntime().exec(command);

I want to get the jar file path from maven. What should be the value of jarPath in above command string?

Shashi Ranjan
  • 1,491
  • 6
  • 27
  • 52

1 Answers1

0

Technically the path to your maven installed artifacts should be something like

<user_home_dir>/.m2/repository/com/vmware/vcac/qe/tools/vcac-tools/1.0.0/vcac-tools-1.0.0.jar
Saif Asif
  • 5,516
  • 3
  • 31
  • 48
  • Yes, this works. But the problem here is I don't want to hard code the whole path. Is there any way to get this path in java using some get system/maven property? – Shashi Ranjan Oct 05 '15 at 07:29
  • Another way would be to package the jar with your application. That way it will be available at the classpath of your application and you may be able to access there. What you need is a something similar to a [Uber jar](http://stackoverflow.com/questions/11947037/what-is-an-uber-jar). – Saif Asif Oct 05 '15 at 07:32