1

Jar file class getting executed through command prompt but noClassDefFound when run through shell script object of QTP

I have written a class to fetch data from websphere MQ and saved it as MQTools.Jar runnable.

I try to create a shell scripting object and use Run command Exception in thread "main" java.lang.NoClassDefFoundError: bec/MQ/Tools/MQClass

Set objShell = CreateObject("Wscript.Shell")

If instr(1,objShell.Environment.item("classpath"), strJavaFilePath, 1) > 0 Then 'javafilepath is path to the runnable Jar
Else
    objShell.Environment.item("classpath") = objShell.Environment.item("classpath") & ";"&strJavaFilePath
End If
objShell.Run("cmd /c set classpath="& objShell.Environment.item("classpath"))

intReturn = objShell.Run ("cmd /c java bec.MQ.Tools.MQClass" & " "& strCommandLineArgs, 1, true) 'This line throws noclassdeffound error

I use the same command, copy and paste into a command window, it runs very smoothly without errors. Can anybody please suggest

Mithilesh Indurkar
  • 481
  • 1
  • 5
  • 12

1 Answers1

1

Got it...

The issue here is even if I add the classpath runtime in QTP, QTP will not fetch the classpath until you restart QTP. For a new machine, this problem will occur, for an old machine i.e. a machine where this script is already run before, the classpath would already have the required value in variable and won't come across this issue. This issue is similar to one I have posted earlier but yet to find a solution. Refresh system variable using vbscript/QTP

The problem statement is 'How to reflect changes in system env variables in QTP without having to restart QTP'

Solution: Might be with some geek but unknown to the world yet.

Mithilesh Indurkar
  • 481
  • 1
  • 5
  • 12