• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trying to execute java program which is in jar file

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.




 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic