How to specify a runnable jar to use tomcat's lib for dependencies

Renier

I have made a java project in eclipse that's a runnable jar if I export it.

My structure of my project :

enter image description here

When I export my project as a runnable jar it asks me how I would like my dependencies to be packaged and I choose to put it in a lib folder. So when exporting it exports the runnable jar as well as creates a sub folder with my dependent jar files which I want to be only the 5 jars located in Referenced libraries.

This is the export window :

enter image description here

This creates my runnable jar and then a folder _lib with my other jars.

enter image description here

This works fine but as you see in the first image I also included the Tomcat lib library because some of the jar files in tomcat lib are used by my project.

The problem is that when I export, all the jar files in the tomcat lib get exported to my sub lib folder which I do not want.

Basically I want to deploy my runnable to a server witch will get the dependent jar files from the sub directory lib only those 5 jar files in image (Referenced Libraries). Tomcat is installed on the server so it should point to tomcats lib to get the rest of the jars.

Want my project to use the generated lib folder and then the tomcat lib.

Hope it makes sense what I am trying to ask.

Using Eclipse and java 1.7. developing on windows, deploying to linux running the application via command line on linux box.

Renier

What I have done to get this working is on the linux side to start the java runable class another way by specifying the classpath this will give the class you are trying to run the ability to first check the folders that you specify. So in my example instead of executing my app on the linux box with the following :

nohup java -jar /usr/local/P6/StockListShunter/StockListShunter.jar &

I did the following and specified the Class path lib that java should check for .jar file dependencies :

nohup java -classpath :/usr/mylib1/*:/usr/StockListShunter_lib/*:/usr/share/lib/*:  stockListShunter.Shunter &

Notice I specified 3 libraries java should check when running my runable class, mylib1,StockListShunter_lib and lib.

After you specified the classpath you will see you need to specify your java class witch will be your main method class. In my example it is stockListShunter.Shunter where stockListShunter is my package name.

Just take note that you should make sure that the class you are trying to excecute is included in one of the jar files that you specified in the classpath otherwise it wont find the class and you will get an error : Error: Could not find or load main class stockListShunter.Shunter

So when you run the command the process will be started, my program is in a loop so the process will be alive until I kill it. If your program should be alive you can confirm it is running by running the following command.

ps aux | grep stockListShunter.Shunter

Where stockListShunter.Shunter is your main class name. This should display all the processes where the command has a stockListShunter.Shunter in it.

If you want to end the process like mine that's in a loop you can run the following command.

pkill -f 'java.*stockListShunter.Shunter'

Again where stockListShunter.Shunter is your main class name. This should kill your java process.

Hope this could help some one in the future.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

From Dev

Runnable jar with dependencies

From Java

How to put all dependencies in separate folder for runnable jar?

From Dev

How can I create an executable/runnable JAR with dependencies using Maven?

From Dev

How to specify which jar signer to use in Ivy

From Java

Bundle native dependencies in runnable .jar with Maven

From Dev

Gradle dependencies not being exported to runnable jar by eclipse

From Dev

Deploying a runnable jar in ECLIPSE by considering dependencies

From Dev

How to use runnable jar in java project by importing it to libs folder

From Dev

How to view a runnable .jar's output via SSH client

From Dev

How to Specify External log4j2 Config File in Runnable jar Created with Eclipse

From Dev

Kotlin: How to create a runnable jar?

From Dev

Build Runnable Jar of a JAVA project with JAVAFX as external lib

From Dev

How do I create a Netbeans style Jar with all dependencies in a lib folder?

From Dev

Use Tomcat's "endorsed" directory for JDBC implementation jar?

From Java

How to list dependencies of a JAR

From Dev

How to add a .jar file to webserver's lib directory?

From Java

Build executable .jar with external .jar dependencies copied in a lib folder

From Dev

How to specify dependencies using setuptools?

From Dev

How to specify dependencies for the entire router?

From Java

Unwanted jar files in tomcat/lib or WEB-INF/lib

From Java

How to specify "sources" JAR for local JAR dependency?

From Dev

How to include jar dependencies in EJB jar file?

From Dev

How to import all dependencies of a jar?

From Dev

How to specify the path for .lib files in cmake?

From Dev

How to specify flags for dependencies of a bazel target?

From Dev

How to specify recursive dependencies in setup.py?

From Python

How to specify external system dependencies to a Python package?

From Java

How can I specify JUnit test dependencies?

Related Related

  1. 1

    How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

  2. 2

    Runnable jar with dependencies

  3. 3

    How to put all dependencies in separate folder for runnable jar?

  4. 4

    How can I create an executable/runnable JAR with dependencies using Maven?

  5. 5

    How to specify which jar signer to use in Ivy

  6. 6

    Bundle native dependencies in runnable .jar with Maven

  7. 7

    Gradle dependencies not being exported to runnable jar by eclipse

  8. 8

    Deploying a runnable jar in ECLIPSE by considering dependencies

  9. 9

    How to use runnable jar in java project by importing it to libs folder

  10. 10

    How to view a runnable .jar's output via SSH client

  11. 11

    How to Specify External log4j2 Config File in Runnable jar Created with Eclipse

  12. 12

    Kotlin: How to create a runnable jar?

  13. 13

    Build Runnable Jar of a JAVA project with JAVAFX as external lib

  14. 14

    How do I create a Netbeans style Jar with all dependencies in a lib folder?

  15. 15

    Use Tomcat's "endorsed" directory for JDBC implementation jar?

  16. 16

    How to list dependencies of a JAR

  17. 17

    How to add a .jar file to webserver's lib directory?

  18. 18

    Build executable .jar with external .jar dependencies copied in a lib folder

  19. 19

    How to specify dependencies using setuptools?

  20. 20

    How to specify dependencies for the entire router?

  21. 21

    Unwanted jar files in tomcat/lib or WEB-INF/lib

  22. 22

    How to specify "sources" JAR for local JAR dependency?

  23. 23

    How to include jar dependencies in EJB jar file?

  24. 24

    How to import all dependencies of a jar?

  25. 25

    How to specify the path for .lib files in cmake?

  26. 26

    How to specify flags for dependencies of a bazel target?

  27. 27

    How to specify recursive dependencies in setup.py?

  28. 28

    How to specify external system dependencies to a Python package?

  29. 29

    How can I specify JUnit test dependencies?

HotTag

Archive