aspose file tools*
The moose likes Java in General and the fly likes Trying to execute java program which is in jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trying to execute java program which is in jar file" Watch "Trying to execute java program which is in jar file" New topic
Author

Trying to execute java program which is in jar file

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
I am Trying to execute java program which is in jar file

set JAVA_HOME="C:\Program Files\Java\jdk1.5.0_06"

java -classpath c:\lib;c:\myTest.jar com\test\admin\client\Delta\DeltaTest

it says class not found exception....it's not getting the supported class files, jars which are available in lib folder.

why is it so?lib folder is in classpath

Thanks for your help.




Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
Rahul Ba wrote:
why is it so? my class file is in my.jar which is in classpath...

I hope you mean myTest.jar

java -classpath c:\lib;c:\myTest.jar com.test.admin.client.Delta.DeltaTest
or
java -classpath c:\lib;c:\myTest.jar com/test/admin/client/Delta/DeltaTest

"\" is the villain


Experience and talent are independent of age
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

So is /. When executing Java classes, you need to provide the fully qualified name of the class whose main method you want to execute. That means the full package and class name: com.test.admin.client.Delta.DeltaTest


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
ok, Thanks for the input..but the main problem I am facing is that in lib folder there are 20 files. when I right c:\lib in classpath it does not access any supporting jar files.
I need to sepecify

java -classpath c:\lib\file1.jar;c:\lib\file2.jar;c:\lib\file3.jar;c:\lib\file4.jar;c:\lib\file5.jar;c:\lmyTest.jar com.NameoftheClass

I do not want to specify jar in such way...is there way to put folder in to the classpath folder?

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14428
    
  23

You should be able to do this:

java -cp C:\lib\*.jar;C:\myTest.jar com.test.admin.client.Delta.DeltaTest

Note that using a wildcard (*) is a new feature that was added in Java 6; since you're using Java 5, it might not work.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
Rob Prime wrote:So is /. When executing Java classes, you need to provide the fully qualified name of the class whose main method you want to execute. That means the full package and class name: com.test.admin.client.Delta.DeltaTest

Then is it that we should not use a "/" although it works?

Regards
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
Jesper Young wrote:You should be able to do this:

java -cp C:\lib\*.jar;C:\myTest.jar com.test.admin.client.Delta.DeltaTest

Note that using a wildcard (*) is a new feature that was added in Java 6; since you're using Java 5, it might not work.


Actually the * doesn't work quite the way you would expect.
C:\lib\*.jar doesn't match anything, C:\lib\* matches all jar files

Joanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to execute java program which is in jar file