Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a java file with a lot of jars dependencies in ubuntu

I have a java class which has almost 12 jar file dependencies and i am using ubuntu 12.10 . I need to know how to run this java application because every time i run it , it gives me errors as "symbols not found". I have all jar files in a folder called libs. and i have tried these commands but none of these gives me some succesful result.I have flights.java class in test directory and libs directory is inside test directory.Currently i am in test directory

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

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

like image 947
user1708240 Avatar asked Apr 01 '14 19:04

user1708240


People also ask

How do I run a JAR file in Ubuntu?

To run a JAR file on Windows, Mac or Ubuntu machines, follow these steps: Verify that Java is installed on your computer. Confirm the computer's PATH variable includes Java's \bin directory. Double-click the JAR file if auto-run has been configured.


1 Answers

if you have single class in your app called flights.java and all of your required jar are located at /home/ubuntu/test/libs/ then use this

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

and to run

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

better to just pack dependency and app in to a single jar and make it launchable and runnable jar

like image 139
jmj Avatar answered Sep 23 '22 19:09

jmj