PDA

View Full Version : How to execute Java Batch File


RodrigoReboucas
08-31-2009, 06:00 PM
I am trying to execute a Batch file through the "BatchFile" Action/Step and I get the following error:

java.lang.NoClassDefFoundError: fitnesse/FitNesse
Caused by: java.lang.ClassNotFoundException: fitnesse.FitNesse
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: fitnesse.FitNesse. Program will exit.
Exception in thread "main" Press any key to continue . . .

The Batch file uses the java runtime and works great from Windows Explorer but apparently I have to initialize the RT from inside VBP. This is my batch file content:


java -cp fitnesse.jar fitnesse.FitNesse -p 8089 %1 %2 %3 %4 %5
pause

Any thoughts on how to accomplish that?

Thanks,
Rodrigo

kinook
08-31-2009, 06:25 PM
That should work. You may need to specify a 'Start in' path of the location of the .bat file (since no path is specified for the .jar file in the batch file). If that doesn't help, I would suspect some sort of problem with an environment variable needed by java (launching VBP from the same Explorer where the batch file works should cause VBP to inherit the same environment block). You could also call java directly from a Run Program action (since the batch file contains only one command other than a pause statement, which you probably don't want in an automated build anyway).