• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Fergus Red
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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 ]
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!