Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting classpath for multiple jar files

 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to identify all the dependent jars that I need for my code to run
( hence this exercise )

Using JDK 1.5


Trying to compile and run some code from the dos prompt ( purposefully not using Eclipse )

Now while I am able to compile the code I am getting errors while trying to run the same

Incrementally looking at the error - I am adding the necessary jar file in a specific directory .

I then execute the code similar to ::



My Problem is for every jar to be added in classpath manually is a pain

Is it possible to specify a wildcard like *.jar that will include all jars in specified dir

I tried the following ( didnt work )



Is there any other alternative that can be used ?

Thanks ,
~satish
 
Norm Radder
Ranch Hand
Posts: 732
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't seen any wildcards in the tool doc, but every release something changes so you need to keep reading the doc to see if/when it is allowed.

Are the number/names of jar files changing every time? Or are they constant?
Some solutions if the jar files remain constant:
Create a batch file with all the jar files specified in it.
Use Windows Explorer|Tools|File Types to set a commandline for jar files that you can select from the Rightclick context menu.
 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Norm for the response

I tried doing some googling and looks like atleast till Java 1.6 cannot specify a directory that contains jars

Regarding the explorer >> tools >> Folder options >> File types

I am not sure I followed you .

Could you please elaborate how to go about it ?

Thanks ,
~satish
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by satish bodas:
I tried doing some googling and looks like atleast till Java 1.6 cannot specify a directory that contains jars


I guess you need to reconfigure Google to search the Sun Java website then

I haven't actually tried it myself, but according to this
java -classpath .;D:\zzz\* com.embeddable.Client
should work.

[Edit] - note however that you can't do this in a jar manifest classpath, so if you ever decide to package your application as a jar, you will need to know precisely which jar files are used.
[ July 29, 2008: Message edited by: Joanne Neal ]
 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joanne for the link and it does mention the wildcard piece to include jars .

However I did try it out and it didnt work for me

Here is the link where they mention about version 1.6
In Java 1.6+, use a wildcard to include all jars in a directory into the set classpath or the command line -classpath


Thanks ,
~satish
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had a little play and I got it to work. You need to put the classpath variable in quotes
java -classpath ".;D:\zzz\*" com.embeddable.Client
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic