How to run java file with many jars dependencies in ubuntu

I have a java class that has almost 12 jar-dependent files, and I'm using ubuntu 12.10. I need to know how to run this Java application, because every time I run it, it gives me errors, because "characters were not found." I have all the jar files in the libs folder. and I tried these commands, but none of them gave me any successful result. I have a flight.java class in the test directory, and the libs directory is inside the test directory. I'm currently in the test directory

javac -cp "/home/ubuntu/test/libs/*.jar" flight.java

javac -cp '/home/ubuntu/test/libs/*.jar' flights.java

+4
source share
2 answers

if you have one class in your application called flights.javaand all your required jar is in /home/ubuntu/test/libs/, then use this

javac -cp '.:/home/ubuntu/test/libs/*.jar' flights.java

and run

java -cp '.:/home/ubuntu/test/libs/*.jar' flights

it’s better to just pack the addiction and application into one jar and make it a running and running jar

+8
source

12 cans are not very big. Why not just add all the banks to the class path?

Alternatively, you can create another jar and specify all the banks in the Class-Path variable in this MANIFEST.MF jar, and then add this single jar to your classpath.

EDIT:

This is how I do it. Create a MANIFEST.MF file with content similar to this:

Manifest-Version: 1.0    
Archiver-Version: whatever  
Created-By: whatever  
Built-By: author-name  
Build-Jdk: 1.6.0_34  
Class-Path: jar1.jar jar2.jar jar3.jar  

replace jar1.jarthe actual jar file names.

: jar cvf test.jar -m ./MANIFEST.MF.

, classpath, java -jar xyz.jar class-name

+4

Source: https://habr.com/ru/post/1534518/


All Articles