• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How to execute java class held in jar file from dos batch file?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to execute a java class from a dos batch file. The java class exists in a jar file on my Jrun application server.
I have successfully executed java classes from batch commands before, however on these instances the java class did not reside in a jar file. In this instance, I cannot seem to execute my java class that resides in my jar file.
My batch command is as follows
C:\jdk1.3\bin\java -cp d:\Allaire\jrun\servers\server10\default-app\web-inf\classes\utils.jar dev.projectA.utils.TriggerEmailDispatchTest
When I try to execute the batch command it seems as if it has run currently, however it does not execute my Java class as rewquired.
Can you see where I am going wrong? Or what do I need to do differently to execute a java class from a dos batch file?
The reason I am executing this from a batch file is because i will be adding this to my windows scheduler to run at scheduled times.
Cheers in advance for the help.
[ January 20, 2003: Message edited by: Fergus Red ]
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your main class reside inside the jar file then
you need to edit the MANIFEST.MF file to point to your main class inside jar
with key value pair as shown
Main-Class: dev.projectA.utils.TriggerEmailDispatchTest
now execute the class with -jar key as shown
C:\jdk1.3\bin\java -jar jarFienName.jar
 
Fergus Red
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I've managed to get it working without altering the manifest file.
I ran the following command
c:
cd jdk1.3\bin
java -cp ;d:\Allaire\jrun\servers\server10\default-app\web-inf\classes\utils.jar dev.projectA.utils.TriggerEmailDispatchTest
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You only need to specify the class name in the manifest file if you intend to double click the jar and have it know what class to execute. If you start the app using the fully qualified name of the class file to invoke then your manifest file can essentially be trivial.
Another way of fixing your problem would have been to append the bin directory to the path, so that the java.exe would be found. That way you would not need to actually "move" the user around.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic