How to execute jar file with a external dependency using command line on Windows?

Xelian

I have jar file with manifest in it

    Manifest-Version: 1.0
    Build-Jdk: 1.7.0_67
    Created-By: Apache Maven 3.2.3
    Main-Class: com.company.main.Main
    Archiver-Version: Plexus Archiver

And the jar has compile dependency to external library

compile 'org.apache.commons:commons-lang3:3.3.2'

So I want to execute it comandLine I wrote:

java -cp C:\commons-lang3-3.3.2.jar -jar myJar-1.0.0.jar

But

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
        at ...

How to add this file on the class path?

PS. If I use the "bad way" and copy-paste commons-lang3-3.3.2.jar in the ...jre7\lib\ext folder. Everything is working.

Tom Bunting

If you're not using the -jar option then you need to specify the main class to run, as the manifest will not be interrogated:

java -cp C:\commons-lang3-3.3.2.jar;.\myJar-1.0.0.jar com.company.main.Main

The classpath (-cp) option is ignored if using the -jar option (in that case the manifest should reference any other required jars via its classpath directive).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to execute jar file with a external dependency using command line on Windows?

From Dev

execute jar file in command line using third party jar

From Dev

How to execute an external PHP file from a Windows Command Line (bat file)

From Dev

How can I execute jar file in UNIX-like using this command line: java -jar mysolution.jar < inputfile.txt

From Dev

Windows: How to read command-line options from external file?

From Dev

unable to execute the jar file using java program. i need to pass the file path as a command line argument to the jar file

From Dev

How to Run a Java Class File from the Command Line that was Compiled by Eclipse? External Jar problems

From Dev

How to add an external library (OpenCV .jar file) to the Java build path from the command line (Unix)

From Dev

Adding external dependencies to a jar file through the command line

From Dev

Failed to run java in remote command line with external jar file

From Dev

how to read a file external to the jar // getResource issue with mysql dependency in pom

From Dev

IBM MobileFirst: using external jar files during command line build

From Dev

IBM MobileFirst: using external jar files during command line build

From Dev

How to replace a file in jar with command line in linux?

From Dev

How to execute diff on the command line using Go?

From Dev

How to execute a command in windows cmd using Gradle?

From Dev

How do you execute command line tools without using batch file in Inno Setup

From Dev

How to execute a find command using a set of strings from a line in a text file

From Dev

How to attach a pointcut to a to a method of class residing inside a .jar file using command line?

From Dev

How to compile set of java files in different packages and then build .jar file using command line?

From Dev

Running wordcount.jar on hadoop in windows using command line

From Dev

How to execute a main class in a jar from gradle using the 'java' command

From Dev

Controlling output file of a java jar using command line

From Dev

Shortcut to execute .jar in command line (terminal)

From Java

How to create an empty file at the command line in Windows?

From Dev

How to run a .py file in windows command line?

From Dev

How to execute FreePascal from windows command line as "fpc"

From Dev

How can I execute a Windows command line in background?

From Dev

How to Execute ShortCut From Command line in Windows 7

Related Related

  1. 1

    How to execute jar file with a external dependency using command line on Windows?

  2. 2

    execute jar file in command line using third party jar

  3. 3

    How to execute an external PHP file from a Windows Command Line (bat file)

  4. 4

    How can I execute jar file in UNIX-like using this command line: java -jar mysolution.jar < inputfile.txt

  5. 5

    Windows: How to read command-line options from external file?

  6. 6

    unable to execute the jar file using java program. i need to pass the file path as a command line argument to the jar file

  7. 7

    How to Run a Java Class File from the Command Line that was Compiled by Eclipse? External Jar problems

  8. 8

    How to add an external library (OpenCV .jar file) to the Java build path from the command line (Unix)

  9. 9

    Adding external dependencies to a jar file through the command line

  10. 10

    Failed to run java in remote command line with external jar file

  11. 11

    how to read a file external to the jar // getResource issue with mysql dependency in pom

  12. 12

    IBM MobileFirst: using external jar files during command line build

  13. 13

    IBM MobileFirst: using external jar files during command line build

  14. 14

    How to replace a file in jar with command line in linux?

  15. 15

    How to execute diff on the command line using Go?

  16. 16

    How to execute a command in windows cmd using Gradle?

  17. 17

    How do you execute command line tools without using batch file in Inno Setup

  18. 18

    How to execute a find command using a set of strings from a line in a text file

  19. 19

    How to attach a pointcut to a to a method of class residing inside a .jar file using command line?

  20. 20

    How to compile set of java files in different packages and then build .jar file using command line?

  21. 21

    Running wordcount.jar on hadoop in windows using command line

  22. 22

    How to execute a main class in a jar from gradle using the 'java' command

  23. 23

    Controlling output file of a java jar using command line

  24. 24

    Shortcut to execute .jar in command line (terminal)

  25. 25

    How to create an empty file at the command line in Windows?

  26. 26

    How to run a .py file in windows command line?

  27. 27

    How to execute FreePascal from windows command line as "fpc"

  28. 28

    How can I execute a Windows command line in background?

  29. 29

    How to Execute ShortCut From Command line in Windows 7

HotTag

Archive