include external jar when running java -jar

rouble :

From my readings, when you execute a command as follows:

java -jar foo.jar

Then the main classpath is ignored, and the classpath is taken from the manifest file.

Further, the classpath declared on the command line is also ignored. So in:

java -classpath /usr/local/jar/foobar.jar -jar foo.jar

/usr/local/jar/foobar.jar is ignored.

Lastly, I have read that the manifest file can only contain relative paths, within the jar file.

So, how do you include absolute paths to external jars, that are present on the system, but not in the jar file being executed?

matt b :

Is there a reason why you are avoiding invoking the main class like

java -cp /usr/local/jar/foobar.jar:/some/other/path.jar com.your.main.classname

?

This type of invocation allows you to mix absolute paths with relative paths. Put this into a shell script or batch file to avoid having to actually type or remember the full classpath to simplify things.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Running Java 8 jar when only Java 11 JRE is available

From Java

Java command line with external .jar

From Java

Android: Include External Jar in Build (Without Eclipse)

From Java

Java Jar Ant include folder

From Java

How to include an external JAR in a directory within the Java classpath and run the Java class?

From Java

How do i include external .jar in my gradle java project?

From Java

Running java runnable JAR

From Java

ClassNotFoundException when using external jar

From Java

Java code in vscode console not running correctly when packaged as .jar

From Dev

Maven: How to include my external jar into build executable jar

From Dev

java.lang.NoClassDefFoundError when running a spark jar application

From Dev

How to get unix process ID when running java -jar command

From Dev

How to include a xhtml from an external jar

From Dev

Could not find the main class: when running Java Jar?

From Dev

Spring Boot Jersey - Missing EmbeddedServletContainerFactory when running java -jar command

From Dev

Java not honoring the classpath specification with -cp option when running with a jar

From Dev

Compiling and running using external jar files

From Dev

Ninja Framework Include External Jar

From Dev

java - error while running compiled program with external jar

From Dev

IntelliJ include external JARS in JavaFX JAR file

From Dev

NoSuchFileException when running jar file

From Dev

How to include external jar in library project output classes.jar

From Dev

Jitsi include external jar for customization

From Dev

Java can't find native libraries when running Clojure JAR

From Dev

Java properties file in jar not found when running jar

From Dev

Java jar file not running

From Dev

java.lang.NoSuchMethodError When Running A Code From External .jar

From Dev

How to build a Jar file that include external files

From Dev

Jar Files not working when I include external dependencies in my project in Intellij

Related Related

  1. 1

    Running Java 8 jar when only Java 11 JRE is available

  2. 2

    Java command line with external .jar

  3. 3

    Android: Include External Jar in Build (Without Eclipse)

  4. 4

    Java Jar Ant include folder

  5. 5

    How to include an external JAR in a directory within the Java classpath and run the Java class?

  6. 6

    How do i include external .jar in my gradle java project?

  7. 7

    Running java runnable JAR

  8. 8

    ClassNotFoundException when using external jar

  9. 9

    Java code in vscode console not running correctly when packaged as .jar

  10. 10

    Maven: How to include my external jar into build executable jar

  11. 11

    java.lang.NoClassDefFoundError when running a spark jar application

  12. 12

    How to get unix process ID when running java -jar command

  13. 13

    How to include a xhtml from an external jar

  14. 14

    Could not find the main class: when running Java Jar?

  15. 15

    Spring Boot Jersey - Missing EmbeddedServletContainerFactory when running java -jar command

  16. 16

    Java not honoring the classpath specification with -cp option when running with a jar

  17. 17

    Compiling and running using external jar files

  18. 18

    Ninja Framework Include External Jar

  19. 19

    java - error while running compiled program with external jar

  20. 20

    IntelliJ include external JARS in JavaFX JAR file

  21. 21

    NoSuchFileException when running jar file

  22. 22

    How to include external jar in library project output classes.jar

  23. 23

    Jitsi include external jar for customization

  24. 24

    Java can't find native libraries when running Clojure JAR

  25. 25

    Java properties file in jar not found when running jar

  26. 26

    Java jar file not running

  27. 27

    java.lang.NoSuchMethodError When Running A Code From External .jar

  28. 28

    How to build a Jar file that include external files

  29. 29

    Jar Files not working when I include external dependencies in my project in Intellij

HotTag

Archive