Include all the jars in a directory within the Java classpath

0 votes

how can we include all the jar files within a directory in the same classpath?

My attempt:  java -classpath lib/*.jar:. my.pack.Code1 and it is not able to find class files that are certainly in those jars. Do we need to add each jar file to the classpath separately one by one?

May 22, 2018 in Java by sharth
• 3,320 points
1,730 views

2 answers to this question.

0 votes
Windows:
java -cp ppp.jar;dir/* my.app.ClassName

Linux:
java -cp ppp.jar:dir/* my.app.ClassName

Note: 
Windows path separator is ";"
Linux path separator is ":"

In 
Windows if cp argument does not contains white space, the "quotes" is optional

answered May 22, 2018 by parth295
• 4,600 points
0 votes
Just use lib/*   not lib/*.jar  

That's the syntax 'java' uses.
answered Apr 6 by anonymous

Related Questions In Java

0 votes
1 answer

Get all the permutations of a string in Java

This is the recursive way of finding a ...READ MORE

answered May 10, 2018 in Java by sharth
• 3,320 points
69 views
0 votes
1 answer

Listing all the subclasses of a specific class in Java

There is a simple library available for ...READ MORE

answered Jun 7, 2018 in Java by geek.erkami
• 2,320 points
124 views
0 votes
2 answers

What's the best way to check if a String represents an integer in Java?

You can also use regular expression. str.matches("-?\\d+"); It will ...READ MORE

answered Aug 9, 2018 in Java by Daisy
• 8,040 points
104 views
0 votes
2 answers

How can I get the filenames of all files in a folder which may or may not contain duplicates

List<String> results = new ArrayList<String>(); File[] files = ...READ MORE

answered Sep 12, 2018 in Java by Sushmita
• 6,840 points
587 views
0 votes
1 answer

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

answered May 25, 2018 in Java by geek.erkami
• 2,320 points
741 views
0 votes
1 answer

How to run the JAR files in windows?

Following are the steps to run the ...READ MORE

answered May 28, 2018 in Java by parth295
• 4,600 points
58 views
0 votes
1 answer

How to run a JAR file in Java?

The command given below will help you ...READ MORE

answered Jun 1, 2018 in Java by parth295
• 4,600 points
317 views
+1 vote
10 answers

Unable to execute jar- file: “no main manifest attribute”

You Can Simply follow this step Create ...READ MORE

answered Dec 10, 2018 in Java by Sukesh
15,141 views
0 votes
3 answers

How to read a Text File in Java?

You can use readAllLines and the join method to ...READ MORE

answered Jul 27, 2018 in Java by samarth295
• 2,190 points
59 views
0 votes
2 answers

How to find out current working directory in Java?

You can also use java.nio.file.Path and java.nio.file.Paths. Path ...READ MORE

answered Jul 30, 2018 in Java by Sushmita
• 6,840 points
29 views