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

Trying to execute java program which is in jar file

 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rahul Ba
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic